-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub workflow to build Docker image from tags
This workflow will be triggered when any tag, that match the semi- regex (it is not normal regex, since "." is treated as a normal period here), is pushed to the repository. The helper script will then properly extract the version numbers we are interested in, before the Docker image is built and tagged properly. More info about this can be found in issue #28: #28
- Loading branch information
1 parent
e941b81
commit 06c1c67
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This is a small helper script used to extract and verify the tag that is to | ||
# be set on the Docker container. This file expects that the GitHub Action | ||
# variable GITHUB_REF is passed in as the one and only argument. | ||
|
||
if [ -z "${1}" ]; then | ||
echo "Input argument was empty" | ||
exit 1 | ||
fi | ||
|
||
app_version=$(echo ${1} | sed -n -r -e 's&^refs/.+/v([1-9]\.[0-9]+\.[0-9]+).*$&\1&p') | ||
nginx_version=$(echo ${1} | sed -n -r -e 's&^refs/.+/.*-nginx([1-9]\.[0-9]+\.[0-9]+)$&\1&p') | ||
|
||
if [ -n "${app_version}" -a -n "${nginx_version}" ]; then | ||
echo "::set-output name=APP_VERSION::${app_version}" | ||
echo "::set-output name=NGINX_VERSION::${nginx_version}" | ||
else | ||
echo "Could not extract all expected values:" | ||
echo "APP_VERSION=${app_version}" | ||
echo "NGINX_VERSION=${nginx_version}" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: "build-tags" | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- "**" | ||
tags: | ||
- "v[1-9].[0-9]+.[0-9]+-nginx[1-9].[0-9]+.[0-9]+" | ||
|
||
jobs: | ||
docker_buildx: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Extract version numbers from GitHub reference | ||
id: tagger | ||
run: bash .github/version_extractor.sh ${GITHUB_REF} | ||
|
||
- name: Set up QEMU environment | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push all images | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: ./src | ||
platforms: | | ||
linux/amd64 | ||
linux/386 | ||
linux/arm64 | ||
linux/arm/v7 | ||
pull: true | ||
no-cache: true | ||
push: true | ||
build-args: BUILDX_QEMU_ENV=true | ||
tags: | | ||
jonasal/nginx-certbot:${{ steps.tagger.outputs.APP_VERSION }} | ||
jonasal/nginx-certbot:${{ steps.tagger.outputs.APP_VERSION }}-nginx${{ steps.tagger.outputs.NGINX_VERSION }} |