Pull and Push Docker Image #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pull and Push Docker Image | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| image_tag: | |
| description: "Balrog image tag to pull from Docker Hub" | |
| required: true | |
| type: string | |
| jobs: | |
| push: | |
| environment: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: gcp-auth | |
| name: Google authentication | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| token_format: "access_token" | |
| service_account: artifact-writer@${{ vars.GCP_PROJECT_ID }}.iam.gserviceaccount.com | |
| workload_identity_provider: ${{ vars.GCPV2_GITHUB_WORKLOAD_IDENTITY_PROVIDER }} | |
| - name: Pull agent image | |
| run: docker pull mozilla/balrogagent:${{ github.event.inputs.image_tag }} | |
| - name: Pull app image | |
| run: docker pull mozilla/balrog:${{ github.event.inputs.image_tag }} | |
| - name: Log in to GAR for push | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ${{ vars.GAR_LOCATION }}-docker.pkg.dev | |
| username: oauth2accesstoken | |
| password: ${{ steps.gcp-auth.outputs.access_token }} | |
| - name: Tag agent image | |
| run: docker tag mozilla/balrogagent:${{ github.event.inputs.image_tag }} ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/balrogagent:${{ github.event.inputs.image_tag }} | |
| - name: Push agent image | |
| run: docker push ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/balrogagent:${{ github.event.inputs.image_tag }} | |
| - name: Tag app image | |
| run: docker tag mozilla/balrog:${{ github.event.inputs.image_tag }} ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/balrog:${{ github.event.inputs.image_tag }} | |
| - name: Push app image | |
| run: docker push ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/balrog:${{ github.event.inputs.image_tag }} |