-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (120 loc) · 4.6 KB
/
toolbox-base.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: 'Build and Push - Base Toolbox'
on:
push:
tags:
- 'base'
workflow_dispatch:
inputs:
hubVersion:
description: 'Hub CLI 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: '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'
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 CTL version can't be empty"
exit 1
fi
fi
HUB_EXTENSIONS_VERSION=$(git ls-remote -q https://github.com/epam/hub-extensions.git "${{ env.HUB_EXT_REF }}" 2>/dev/null | cut -c-7)
echo "HUB_CTL_VERSION=$HUB_CTL_VERSION" >> $GITHUB_ENV
echo "HUB_EXTENSIONS_VERSION=$HUB_EXTENSIONS_VERSION" >> $GITHUB_ENV
echo "DOCKER_IMAGE_TAG=$(date +"%Y%m%d-%H%M%S")" >> $GITHUB_ENV
-
name: Image meta
id: meta
uses: docker/metadata-action@v4
env:
CUSTOM_TAG: ${{ inputs.customTag || env.DOCKER_IMAGE_TAG }}
with:
flavor: |
latest=true
images: |
ghcr.io/epam/hub-toolbox
tags: |
type=raw,value=${{ env.DOCKER_IMAGE_TAG }},enable=${{ inputs.customTag == '' }},suffix=-base
type=raw,value=${{ env.DOCKER_IMAGE_TAG }},enable=${{ inputs.customTag == '' }}
type=raw,value=base,enable=${{ inputs.customTag == '' }}
type=raw,value=${{ env.CUSTOM_TAG }},enable=${{ inputs.customTag != '' }},prefix=custom-base-
-
name: 'Build and push'
uses: "docker/build-push-action@v3"
with:
context: ./base
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_VERSION=${{ env.HUB_CTL_VERSION }}
HUB_EXTENSIONS_VERSION=${{ inputs.hubExtCommit || env.HUB_EXTENSIONS_VERSION }}
-
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 tag -a "aws" -m "Base Toolbox release - $TAG" --force
git tag -a "gcp" -m "Base Toolbox release - $TAG" --force
git tag -a "azure" -m "Base Toolbox release - $TAG" --force
# Do not use --tags because `base` is also tag
git push origin "$TAG"
git push origin "aws" --force
git push origin "gcp" --force
git push origin "azure" --force
echo "Start workflow for toolbox-aws"
gh workflow run toolbox-aws.yaml
echo "Start workflow for toolbox-azure"
gh workflow run toolbox-azure.yaml
echo "Start workflow for toolbox-gcp"
gh workflow run toolbox-gcp.yaml