-
Notifications
You must be signed in to change notification settings - Fork 44
31 lines (27 loc) · 1.19 KB
/
image_addtag_prod.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
on:
workflow_dispatch:
inputs:
name:
description: 'GCR image microservice name like gintaa-user'
required: true
default: 'gintaa-user'
name: GCR Image Add Tag - prod
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_POC }}
jobs:
build:
name: GCR Image Add Tag
runs-on: ubuntu-latest
steps:
- name: 'Authenticate to Gcloud'
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ env.PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY_POC }}
export_default_credentials: true
- name: 'Adding tags to GCR images'
run: |
echo "gcr.io/${{ env.PROJECT_ID }}/${{ github.event.inputs.name }}"
export LATEST=$(gcloud container images list-tags gcr.io/${{ env.PROJECT_ID }}/${{ github.event.inputs.name }} --limit 1 --format='get(tags)')
echo $LATEST
gcloud container images add-tag gcr.io/${{ env.PROJECT_ID }}/${{ github.event.inputs.name }} gcr.io/${{ env.PROJECT_ID }}/${{ github.event.inputs.name }}:prod-$(case "$LATEST" in ( *"alpha"* ) echo "$LATEST"| cut -d';' -f 1;; esac | cut -d'-' -f 1 --complement) --quiet