diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index a8711fb..9702cd9 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -12,7 +12,7 @@ on: jobs: docker: runs-on: ubuntu-22.04 - name: Docker Push + name: Docker Build and Push steps: - uses: actions/checkout@v4 - name: Log in to Docker Hub @@ -20,12 +20,23 @@ jobs: with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Generate Auth Token + uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} - name: Build test image id: docker-build-test uses: docker/build-push-action@v5 with: target: test push: false + load: true + cache-from: type=gha + cache-to: type=gha,mode=max - name: Run Perl tests run: docker run -i ${{ steps.docker-build-test.outputs.imageid }} - name: Docker meta @@ -46,5 +57,14 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} annotations: ${{ steps.meta.outputs.annotations }} - - if: contains( fromJSON(steps.meta.outputs.json).tags, "${{ github.repository }}:latest") - run: echo 'need update to ${{ fromJSON(steps.meta.outputs.json).tags[0] }}' + cache-from: type=gha + cache-to: type=gha,mode=max + - name: Update deployed image + if: ${{ contains( fromJSON(steps.meta.outputs.json).tags, format('{0}:latest', github.repository)) }} + uses: benc-uk/workflow-dispatch@v1 + with: + repo: metacpan/metacpan-k8s + ref: main + workflow: set-image.yml + token: ${{ steps.app-token.outputs.token }} + inputs: '{ "app": "api-v0-shim", "environment": "prod", "base-tag": "${{ github.repository }}:latest", "tag": "${{ fromJSON(steps.meta.outputs.json).tags[0] }}" }'