-
Notifications
You must be signed in to change notification settings - Fork 11
48 lines (38 loc) · 1.42 KB
/
gcp-tag-artifact.yaml
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
name: GCP Artifact Tagging
on:
release:
types:
- published
jobs:
tag-artifact:
name: Tag GCP artifact
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Google Cloud credentials_json
id: auth
uses: google-github-actions/auth@v1
with:
token_format: "access_token"
credentials_json: ${{ secrets.GOOGLE_CTDAPP_SERVICE_ACCOUNT_CREDENTIALS }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GOOGLE_PROJECT }}
install_components: beta
- name: Login Google Container Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.GOOGLE_REGION }}-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Apply tag to GCP artifact
run: |
docker_registry=${{ secrets.GOOGLE_REGION }}-docker.pkg.dev
image=${{ secrets.GOOGLE_PROJECT }}/${{ secrets.GOOGLE_REPOSITORY }}/cover-traffic
commit_tag=$(git rev-parse --short "$GITHUB_SHA")
tag=${{ github.ref_name }}
echo "Tag from release: ${tag}"
echo "Short sha: ${commit_tag}"
gcloud artifacts docker tags add ${docker_registry}/${image}:${commit_tag} ${docker_registry}/${image}:${tag}