add cd workflow (continuation) #4
Workflow file for this run
This file contains 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: CD | |
on: | |
pull_request: | |
branches: [master] # Temporary trigger | |
workflow_run: | |
workflows: [CI] | |
branches: [master] | |
types: | |
- completed | |
env: | |
GO_VERSION: ^1.21.5 | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
TAG: sha-${{ github.sha }} | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: "read" | |
packages: write | |
id-token: "write" | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Pull image | |
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} | |
- name: Tag image as latest | |
run: docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
- name: Push latest image | |
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
- name: Log into Google Cloud Platform | |
uses: "google-github-actions/auth@v2" | |
with: | |
project_id: "go-modproxy" | |
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER_NAME }} | |
- name: "Set up Google Cloud SDK" | |
uses: "google-github-actions/setup-gcloud@v2" | |
with: | |
version: ">= 461.0.0" |