-
Notifications
You must be signed in to change notification settings - Fork 34
58 lines (47 loc) · 1.93 KB
/
build_publish_image_release.yml
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
name: 📦 Build and Publish a WBS Image Release to Dockerhub
on:
push:
tags:
- 'elasticsearch@*'
- 'quickstatements@*'
- 'wdqs@*'
- 'wdqs-frontend@*'
- 'wdqs-proxy@*'
- 'wikibase@*'
permissions:
contents: write
packages: write
jobs:
extract_and_use_tag:
runs-on: ubuntu-latest
steps:
- name: Extract imageName and confirm it is a valid semantic version tag
id: extract_tag
run: |
# Extract the tag name
TAG_NAME=$(echo ${{ github.ref }} | sed 's/refs\/tags\///')
# Use regex to extract the imageName before the @ and confirm the version is valid semver version tag
if [[ "$TAG_NAME" =~ ^([^@]+)@([0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?)$ ]]; then
# Sets and passes the imageName output from this step, which is used in the subsequent step
# e.g. `steps.extract_tag.outputs.imageName` gets set to "wikibase" matched from "[email protected]")
echo "::set-output name=imageName::${BASH_REMATCH[1]}"
else
echo "Tag does not match the pattern {imageName}@{semantic-version}"
exit 1
fi
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-environment
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
with:
# implicitly docker hub
username: wmdetravisbot
password: ${{ secrets.WBS_PUBLISH_TOKEN }}
- name: Build image and push to Dockerhub with release tags
run: |
set -e # abort on error
set -x # show commands
git config --global user.name 'wikibase suite github actions bot'
git config --global user.email '[email protected]'
./nx release publish -p ${{ steps.extract_tag.outputs.imageName }}