From f3fbbf01402fc7491e044f160edca06ef793eb50 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 30 Nov 2021 16:00:59 +0100 Subject: [PATCH] Add docker github action --- .github/workflows/docker.yml | 70 ++++++++++++++++++++++++++++++++++++ .github/workflows/stats.yml | 2 +- .gitlab-ci.yml | 44 ----------------------- 3 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..b4ff1a452 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,70 @@ +name: Docker + +on: + push: + branches: + - 'master' + schedule: + - cron: '0 3 * * *' + +jobs: + generate-matrix: + name: Generate matrix for Docker build + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: master + - name: Set matrix for build + id: set-matrix + run: | + # FIXME: https://github.com/actions/checkout/issues/290 + git fetch --force --tags + + one="{ \"file\": \"./support/docker/production/Dockerfile.bullseye\", \"ref\": \"develop\", \"tags\": \"chocobozzz/peertube-test:develop-bullseye\" }" + two="{ \"file\": \"./support/docker/production/Dockerfile.buster\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube-test:production-buster,chocobozzz/peertube-test:$(git describe --abbrev=0)-buster\" }" + three="{ \"file\": \"./support/docker/production/Dockerfile.nginx\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube-webserver-test:latest\" }" + + matrix="[$one,$two,$three]" + echo ::set-output name=matrix::{\"include\":$(echo $matrix)} + + docker: + runs-on: ubuntu-latest + + needs: generate-matrix + + strategy: + matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} + fail-fast: false + + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - + name: Checkout develop + uses: actions/checkout@v2 + with: + ref: ${{ matrix.ref }} + - + name: Docker build + uses: docker/build-push-action@v2 + with: + context: '.' + platforms: linux/amd64,linux/arm64 + push: true + file: ${{ matrix.file }} + tags: ${{ matrix.tags }} diff --git a/.github/workflows/stats.yml b/.github/workflows/stats.yml index d6213deed..e50c14720 100644 --- a/.github/workflows/stats.yml +++ b/.github/workflows/stats.yml @@ -1,4 +1,4 @@ -name: Stats" +name: Stats on: push: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad94c8cab..66c6df761 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,47 +38,3 @@ build-nightly: - eval `ssh-agent -s` - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then ssh-add <(echo "${DEPLOYEMENT_KEY}"); fi - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then scp ./peertube-nightly-* ${DEPLOYEMENT_USER}@${DEPLOYEMENT_HOST}:../../web/nightly; fi - -.docker: &docker - stage: docker-nightly - cache: {} - image: - name: gcr.io/kaniko-project/executor:debug - entrypoint: [""] - before_script: - - mkdir -p /kaniko/.docker - - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$CI_REGISTRY_AUTH\",\"email\":\"$CI_REGISTRY_EMAIL\"}}}" > /kaniko/.docker/config.json - script: - - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $DOCKERFILE --destination $DOCKER_IMAGE_NAME - -build-docker-develop: - <<: *docker - only: - - schedules - variables: - DOCKER_IMAGE_NAME: chocobozzz/peertube:develop-bullseye - DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.bullseye - -build-docker-webserver: - <<: *docker - only: - - schedules - variables: - DOCKER_IMAGE_NAME: chocobozzz/peertube-webserver - DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.nginx - -build-docker-tag: - <<: *docker - only: - - tags - variables: - DOCKER_IMAGE_NAME: chocobozzz/peertube:$CI_COMMIT_TAG-bullseye - DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.bullseye - -build-docker-master: - <<: *docker - only: - - master - variables: - DOCKER_IMAGE_NAME: chocobozzz/peertube:production-bullseye - DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.bullseye