Skip to content
This repository was archived by the owner on May 2, 2024. It is now read-only.

Commit 6bdb6d1

Browse files
FEAT: Artifact registry tag workflow (#7)
* upload artifact registry tag workflow * add newline
1 parent 43afd94 commit 6bdb6d1

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/docker.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
env:
9+
PROJECT_ID: portal-gb-prod
10+
REPOSITORY: transaction-http-db
11+
IMAGE: transaction-http-db
12+
REGISTRY: us-central1-docker.pkg.dev
13+
14+
jobs:
15+
login-build-push:
16+
name: Docker login, build, and push
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v1
25+
26+
- id: 'auth'
27+
name: 'Authenticate to Google Cloud'
28+
uses: 'google-github-actions/[email protected]'
29+
with:
30+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
31+
token_format: 'access_token'
32+
33+
- name: Login to GAR
34+
uses: docker/login-action@v2
35+
with:
36+
registry: "${{ env.REGISTRY }}"
37+
username: oauth2accesstoken
38+
password: ${{ steps.auth.outputs.access_token }}
39+
40+
- name: Get tag
41+
id: get-tag
42+
run: echo ::set-output name=short_ref::${GITHUB_REF#refs/*/}
43+
44+
- id: docker-push-tagged
45+
name: Tag Docker image and push to Google Artifact Registry
46+
uses: docker/build-push-action@v2
47+
with:
48+
build-args: GITHUB_TOKEN=${{ secrets.GH_ACCESS_TOKEN }}
49+
push: true
50+
tags: |
51+
${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:${{ steps.get-tag.outputs.short_ref }}
52+
${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:latest

0 commit comments

Comments
 (0)