-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (46 loc) · 1.77 KB
/
google-cloud.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
name: Build and Push Node Project Docker Image to Google Artifact Registry
on:
push:
branches: [main]
permissions:
contents: 'read'
id-token: 'write'
jobs:
build-push-gcr:
name: Build and Push to Google Artifact Registry
runs-on: ubuntu-latest
env:
IMAGE_NAME: fire-daily-bot
PROJECT_ID: fire-daily-news
steps:
- name: Checkout
uses: actions/checkout@v4
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.SERVICE_ACCOUNT_KEY }}'
- uses: google-github-actions/setup-gcloud@main
with:
service_account_key: ${{ secrets.SERVICE_ACCOUNT_KEY }}
project_id: ${{ env.PROJECT_ID }}
export_default_credentials: true
- name: Build Docker Image
run: docker build -t $IMAGE_NAME:latest . --platform=linux/amd64
- name: Automatic Tagging of Releases
id: increment-git-tag
run: |
bash ./scripts/git_update.sh -v major
- name: Configure Docker Client
run: |-
gcloud auth configure-docker --quiet
gcloud auth configure-docker us-central1-docker.pkg.dev --quiet
- name: Push Docker Image to Docker Artifact Registry
env:
GIT_TAG: ${{ steps.increment-git-tag.outputs.git-tag }}
run: |-
docker tag $IMAGE_NAME:latest us-central1-docker.pkg.dev/$PROJECT_ID/docker-image/$IMAGE_NAME:latest
docker tag $IMAGE_NAME:latest us-central1-docker.pkg.dev/$PROJECT_ID/docker-image/$IMAGE_NAME:$GIT_TAG
docker push us-central1-docker.pkg.dev/$PROJECT_ID/docker-image/$IMAGE_NAME:latest
docker push us-central1-docker.pkg.dev/$PROJECT_ID/docker-image/$IMAGE_NAME:$GIT_TAG