-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (74 loc) · 2.34 KB
/
toolbox-gcp.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: 'Build and Push - GCP Toolbox'
on:
push:
tags:
- 'gcp'
workflow_dispatch:
inputs:
customTag:
description: 'Custom base image tag. Empty value triggers release build'
required: false
default: ''
jobs:
build:
runs-on: 'ubuntu-latest'
steps:
-
name: 'Checkout'
uses: 'actions/checkout@v3'
-
name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: 'Set up Docker Buildx'
uses: 'docker/setup-buildx-action@v2'
with:
platforms: linux/amd64
-
id: 'versions'
name: 'Collect versions info'
run: |
echo "DOCKER_IMAGE_TAG=$(date +"%Y%m%d-%H%M%S")" >> $GITHUB_ENV
-
name: Image meta
id: meta
uses: docker/metadata-action@v4
with:
flavor: |
latest=false
images: |
ghcr.io/epam/hub-toolbox
tags: |
type=raw,value=${{ env.DOCKER_IMAGE_TAG }},enable=${{ inputs.customTag == '' }},suffix=-gcp
type=raw,value=gcp,enable=${{ inputs.customTag == '' }}
type=raw,value=${{ inputs.customTag }},enable=${{ inputs.customTag != '' }},prefix=custom-gcp-
- name: 'Build and push'
uses: "docker/build-push-action@v3"
with:
context: ./gcp
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
-
name: 'Tag release'
if: ${{ inputs.customTag == '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USERNAME: ${{ github.event.head_commit.author.name || github.actor }}
USEREMAIL: ${{ github.event.head_commit.author.email || format('{0}@users.noreply.github.com', github.actor) }}
run: |
echo "Setup git"
git config user.name "$USERNAME"
git config user.email "$USEREMAIL"
gh auth setup-git
echo "Create git tag and push it"
TAG="${{ steps.meta.outputs.version }}"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"