Skip to content

Commit

Permalink
feat: add production pipeline (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmeds authored May 23, 2024
1 parent 961d822 commit b310a91
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/cicd-prd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,56 @@ jobs:
run: |
cd ${{ matrix.path }}
make image/build-and-push
deploy-to-production:
needs: [build-makefile]
permissions:
id-token: write
contents: write
runs-on: ubuntu-22.04
if: github.event_name == 'release'
strategy:
fail-fast: false
matrix:
application:
- developer-portal
env:
APP_NAME: ${{ matrix.application }}
Z_ENV: infra/live/gcp/production/prj-p-prod-apps/z_ase1.yaml
Z_SERVICE_ACCOUNT: ${{ secrets.GCP_PRD_GITHUB_SA_K8S_DEPLOY }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PRD }}
GITHUB_PAT: ${{ secrets.GH_PAT }}
Z_IMAGE: asia-docker.pkg.dev/prj-p-devops-services-tvwmrf63/zilliqa-private/z:latest
REGISTRY: asia-docker.pkg.dev
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: Zilliqa/devops
token: ${{ env.GITHUB_PAT }}
ref: main
sparse-checkout: |
${{ env.Z_ENV }}
- name: Authenticate to Google Cloud
id: google-auth
uses: google-github-actions/auth@v2
with:
token_format: "access_token"
workload_identity_provider: "${{ secrets.GCP_PRD_GITHUB_WIF }}"
service_account: ${{ env.Z_SERVICE_ACCOUNT }}
create_credentials_file: true

- name: Deploy application
run: |
gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://${{ env.REGISTRY }}
docker run --rm \
-e ZQ_USER='${{ env.Z_SERVICE_ACCOUNT }}' \
-e Z_ENV='/devops/${{ env.Z_ENV }}' \
-e OP_SERVICE_ACCOUNT_TOKEN='${{ env.OP_SERVICE_ACCOUNT_TOKEN }}' \
-e GITHUB_PAT='${{ env.GITHUB_PAT }}' \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE='/google/application_default_credentials.json' \
-v `pwd`:/devops \
-v ${{ steps.google-auth.outputs.credentials_file_path }}:/google/application_default_credentials.json \
--name z_container ${{ env.Z_IMAGE }} \
bash -c "gcloud config set account ${{ env.Z_SERVICE_ACCOUNT }} && z /app /devops app sync --cache-dir .cache ${{ env.APP_NAME }}"
5 changes: 3 additions & 2 deletions .github/workflows/cicd-stg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ jobs:
make image/build-and-push
deploy-to-staging:
needs: [ build-makefile ]
needs: [build-makefile]
permissions:
id-token: write
contents: write
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]' && github.ref_name == 'main'
strategy:
fail-fast: false
matrix:
Expand All @@ -111,7 +112,7 @@ jobs:
ref: main
sparse-checkout: |
${{ env.Z_ENV }}
- name: Authenticate to Google Cloud
id: google-auth
uses: google-github-actions/auth@v2
Expand Down

0 comments on commit b310a91

Please sign in to comment.