Skip to content

update GCP connexion #4

update GCP connexion

update GCP connexion #4

Workflow file for this run

name: NodeJs GCP Artifact Registry CI
on:
push:
branches: [ "main" ]
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_PROJECT_NUMBER: ${{ secrets.GCP_PROJECT_NUMBER }}
GCP_REGION: us-east4
GCP_REPSOSIROTY: emp-mng-system
GCP_APPLICATION_NAME: employee-management-api
jobs:
build-test-and-push:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up node.js
uses: actions/[email protected]
with:
node-version: '20.10'
cache: 'npm'
- name: Install dependencies
run: |
npm install
- name: Build
run: |
npm run build --if-present
- name: IT Test
run: |
npm run test --if-present
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Build Container
run: |-
docker build -t "${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_REPSOSIROTY }}/${{ env.GCP_APPLICATION_NAME }}:latest" .
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
token_format: access_token
workload_identity_provider: 'projects/${{ env.GCP_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/backend-gh-wif-pool/providers/backend-gh-wif-provider'
service_account: 'github-actions-ar-sa@${{ env.GCP_PROJECT_ID }}.iam.gserviceaccount.com'
- name: Authenticate Docker to Google Cloud Artifact Registry
id: docker-auth
uses: 'docker/login-action@v3'
with:
registry: ${{ env.GCP_REGION }}-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Push Container
run: |-
docker push "${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_REPSOSIROTY }}/${{ env.GCP_APPLICATION_NAME }}:latest"