-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (90 loc) · 3.43 KB
/
gcp-cloud-shell.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: 'Build and Push - GCP Cloud Shell image'
on:
workflow_dispatch:
inputs:
hubVersion:
description: 'Hub CTL release version. Use "latest" or release number (ex. 1.0.0).'
required: true
default: 'latest'
hubExtRef:
description: 'Hub Extensions git ref.'
required: true
default: 'master'
hubExtCommit:
description: 'Hub Extensions commit hash. If empty Hub Extensions git ref is used.'
required: false
default: ''
customTag:
description: 'Name of tag.'
required: false
default: 'latest'
jobs:
build:
runs-on: 'ubuntu-latest'
steps:
-
name: 'Checkout'
uses: 'actions/checkout@v3'
-
id: 'info'
name: 'Gather info'
env:
HUB_CTL_VERSION: ${{ inputs.hubVersion || 'latest' }}
HUB_EXT_REF: ${{ inputs.hubExtRef || 'master' }}
run: |
HUB_CTL_VERSION="${{ env.HUB_CTL_VERSION }}"
if test "$HUB_CTL_VERSION" = "latest"; then
HUB_CTL_VERSION=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/epam/hubctl/releases/latest" | jq -crM '.tag_name | select(.)' | cut -c 2-)
if test -z "$HUB_CTL_VERSION"; then
echo "Hub CLI version can't be empty"
exit 1
fi
fi
HUB_CTL_VERSION_COMMIT=$(git ls-remote -q https://github.com/epam/hubctl.git "v$HUB_CTL_VERSION" 2>/dev/null | cut -c-7)
HUB_EXTENSIONS_VERSION=$(git ls-remote -q https://github.com/epam/hub-extensions.git "${{ env.HUB_EXT_REF }}" 2>/dev/null | cut -c-7)
IMAGE_VERSION=$(echo "${{ github.sha }}" | cut -c-7)
echo "imageVersion=$IMAGE_VERSION" >> $GITHUB_OUTPUT
echo "hubVersion=$HUB_CTL_VERSION" >> $GITHUB_OUTPUT
echo "hubVersionCommit=$HUB_CTL_VERSION_COMMIT" >> $GITHUB_OUTPUT
echo "hubExtVersion=$HUB_EXTENSIONS_VERSION" >> $GITHUB_OUTPUT
-
id: 'versions'
name: 'Calculate versions'
run: |
echo "hubExtVersion=${{ inputs.hubExtCommit || steps.info.outputs.hubExtVersion }}" >> $GITHUB_OUTPUT
-
name: Login to GHCR
uses: docker/#-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
-
name: Image meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/epam/hub-toolbox-gcp-cloud-shell
tags: |
type=raw,value=${{ steps.info.outputs.imageVersion }}-${{ steps.info.outputs.hubVersionCommit }}-${{ steps.versions.outputs.hubExtVersion }}
type=raw,value=${{ inputs.customTag }},enable=${{ inputs.customTag != '' }}
-
name: 'Build and push'
uses: "docker/build-push-action@v3"
with:
context: ./gcp-cloud-shell
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 }}
build-args: |
HUB_CTL_RELEASE_VERSION=${{ steps.info.outputs.hubVersion }}
HUB_EXTENSIONS_VERSION=${{ steps.versions.outputs.hubExtVersion }}