Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment Lock #693

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ env:
VERSION: 1.24.2

jobs:
docker:
docker-production:
if: github.ref_name == 'main'
runs-on: ubuntu-latest
environment: production
defaults:
run:
shell: bash -l {0}
Expand All @@ -28,16 +30,15 @@ jobs:
BUILDKIT_PROGRESS: plain
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
IMAGE_NAME: cpg_workflows
DOCKER_DEV: australia-southeast1-docker.pkg.dev/cpg-common/images-dev
DOCKER_MAIN: australia-southeast1-docker.pkg.dev/cpg-common/images
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

- id: "google-cloud-auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v1"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: "projects/1051897107465/locations/global/workloadIdentityPools/github-pool/providers/github-provider"
service_account: "gh-images-deployer@cpg-common.iam.gserviceaccount.com"
Expand All @@ -63,8 +64,45 @@ jobs:
docker push $DOCKER_MAIN/$IMAGE_NAME:$VERSION
docker push $DOCKER_MAIN/$IMAGE_NAME:latest

docker-dev:
if: github.ref_name != 'main' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
environment: dev
defaults:
run:
shell: bash -l {0}
env:
DOCKER_BUILDKIT: 1
BUILDKIT_PROGRESS: plain
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
IMAGE_NAME: cpg_workflows
DOCKER_DEV: australia-southeast1-docker.pkg.dev/cpg-common/images-dev
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- id: "google-cloud-auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: "projects/1051897107465/locations/global/workloadIdentityPools/github-pool/providers/github-provider"
service_account: "gh-images-dev-deployer@cpg-common.iam.gserviceaccount.com"

- name: set up gcloud sdk
uses: google-github-actions/setup-gcloud@v1
with:
project_id: cpg-common

- name: gcloud docker auth
run: |
gcloud auth configure-docker australia-southeast1-docker.pkg.dev

- name: build
run: |
docker build . -f Dockerfile --tag $IMAGE_NAME:${{ github.sha }}

- name: manually triggered build
if: ${{ github.event_name == 'workflow_dispatch' && github.ref_name != 'main' }}
run: |
docker tag $IMAGE_NAME:${{ github.sha }} $DOCKER_DEV/$IMAGE_NAME:${{github.event.inputs.tag}}
docker push $DOCKER_DEV/$IMAGE_NAME:${{github.event.inputs.tag}}
Loading