diff --git a/.github/workflows/deploy-docker.yaml b/.github/workflows/deploy-docker.yaml index da6600da..379abf1a 100644 --- a/.github/workflows/deploy-docker.yaml +++ b/.github/workflows/deploy-docker.yaml @@ -6,6 +6,11 @@ on: - master tags: - 'v*' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} @@ -18,35 +23,30 @@ jobs: packages: write steps: - - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Log in to the Container registry - uses: docker/login-action@v1 #.10.0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + if: contains(github.ref, 'master') || contains(github.ref, 'tags') with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker + + - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v3 #.5.0 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Build and push + + - name: Build and push id: docker_build - uses: docker/build-push-action@v2 #.7.0 + uses: docker/build-push-action@v5 with: - push: true + push: ${{ contains(github.ref, 'master') || contains(github.ref, 'tags') }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/test-docker.yaml b/.github/workflows/test-docker.yaml new file mode 100644 index 00000000..ce1352a6 --- /dev/null +++ b/.github/workflows/test-docker.yaml @@ -0,0 +1,47 @@ +name: Test Docker image + +on: + push: + branches: + - '*' + - '!master' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + +jobs: + docker: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and save + id: docker_build + uses: docker/build-push-action@v5 + with: + push: ${{ contains(github.ref, 'master') || contains(github.ref, 'tags') }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + outputs: type=docker,dest=/tmp/vpipe-docker.tar + + - name: Upload artifact + uses: actions/upload-artifact@v3 + if: "( !contains(github.ref, 'master') && !contains(github.ref, 'tags') )" + with: + name: vpipe-docker + path: /tmp/vpipe-docker.tar