1- # This workflow build and push a Docker container to Google Artifact Registry
2- # and deploy it on Cloud Run when a commit is pushed to the "main"
3- # branch.
4- #
5- # To configure this workflow:
6- #
7- # 1. Enable the following Google Cloud APIs:
8- #
9- # - Artifact Registry (artifactregistry.googleapis.com)
10- # - Cloud Run (run.googleapis.com)
11- # - IAM Credentials API (iamcredentials.googleapis.com)
12- #
13- # You can learn more about enabling APIs at
14- # https://support.google.com/googleapi/answer/6158841.
15- #
16- # 2. Create and configure a Workload Identity Provider for GitHub:
17- # https://github.com/google-github-actions/auth#preferred-direct-workload-identity-federation.
18- #
19- # Depending on how you authenticate, you will need to grant an IAM principal
20- # permissions on Google Cloud:
21- #
22- # - Artifact Registry Administrator (roles/artifactregistry.admin)
23- # - Cloud Run Developer (roles/run.developer)
24- #
25- # You can learn more about setting IAM permissions at
26- # https://cloud.google.com/iam/docs/manage-access-other-resources
27- #
28- # 3. Change the values in the "env" block to match your values.
29-
30- name : ' Build and Deploy to Cloud Run'
1+ name : Deploy Angular Blog to Cloud Run
312
323on :
334 push :
345 branches :
35- - ' main'
36-
37- env :
38- PROJECT_ID : ' angularblogcloud-455518' # TODO: update to your Google Cloud project ID
39- REGION : ' europe-central21' # TODO: update to your region
6+ - main # lub inna gałąź, którą używasz do produkcji
407
418jobs :
429 deploy :
43- runs-on : ' ubuntu-latest'
44-
45- permissions :
46- contents : ' read'
47- id-token : ' write'
10+ name : Build and Deploy
11+ runs-on : ubuntu-latest
4812
4913 steps :
50- - name : ' Checkout'
51- uses : ' actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 ' # actions/checkout@v4
14+ - name : Checkout code
15+ uses : actions/checkout@v3
5216
53- # Configure Workload Identity Federation and generate an access token.
54- #
55- # See https://github.com/google-github-actions/auth for more options,
56- # including authenticating via a JSON credentials file.
57- - name : Google Cloud Auth
58- uses : ' google-github-actions/auth@v2'
17+ - name : Set up Node.js
18+ uses : actions/setup-node@v3
5919 with :
60- credentials_json : ' ${{ secrets.GCP_SA_KEY }}'
61- project_id : ${{ env.PROJECT_ID }}
20+ node-version : ' 18'
6221
63- # BEGIN - Docker auth and build
64- #
65- # If you already have a container image, you can omit these steps.
66- - name : ' Docker Auth'
67- uses : ' docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567' # docker/login-action@v3
68- with :
69- username : ' oauth2accesstoken'
70- password : ' ${{ steps.auth.outputs.auth_token }}'
71- registry : ' ${{ env.REGION }}-docker.pkg.dev'
22+ - name : Install dependencies
23+ run : npm ci
7224
73- - name : ' Build and Push Container'
74- run : |-
75- DOCKER_TAG="$${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}"
76- docker build --tag "${DOCKER_TAG}" .
77- docker push "${DOCKER_TAG}"
78- - name : ' Deploy to Cloud Run'
25+ - name : Build Angular app
26+ run : npm run build --prod
7927
80- # END - Docker auth and build
81-
82- uses : ' google-github-actions/deploy-cloudrun@33553064113a37d688aa6937bacbdc481580be17' # google-github-actions/deploy-cloudrun@v2
28+ - name : Authenticate to Google Cloud
29+ uses : google-github-actions/auth@v2
8330 with :
84- service : ' ${{ env.SERVICE }}'
85- region : ' ${{ env.REGION }}'
86- # NOTE: If using a pre-built image, update the image name below:
87-
88- image : ' ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}'
89- # If required, use the Cloud Run URL output in later steps
90- - name : ' Show output'
91- run : |2-
31+ credentials_json : ' ${{ secrets.GCP_SA_KEY }}'
9232
93- echo ${{ steps.deploy.outputs.url }}
33+ - name : Deploy to Cloud Run using Buildpacks
34+ uses : google-github-actions/deploy-cloudrun@v2
35+ with :
36+ service : angular-blog # nazwa Twojej usługi Cloud Run
37+ region : europe-central2 # dopasuj do regionu
38+ source : .
0 commit comments