|
|
|
name: workflow-docker-release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- '*'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
gcr-dockerhub-build-publish:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up QEMU for multi-arch support
|
|
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to GitHub
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.CR_PAT }}
|
|
|
|
- name: Login to Quay
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: quay.io
|
|
|
|
username: ${{ secrets.QUAY_USERNAME }}
|
|
|
|
password: ${{ secrets.QUAY_TOKEN }}
|
|
|
|
- name: Login to GitLab
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: registry.gitlab.com
|
|
|
|
username: ${{ secrets.GITLAB_USERNAME }}
|
|
|
|
password: ${{ secrets.GITLAB_TOKEN }}
|
|
|
|
- name: Sync GitHub README.md with Docker Hub
|
|
|
|
uses: peter-evans/dockerhub-description@v3
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }} # NOTE: This MUST be the password NOT the token
|
|
|
|
repository: ${{ github.repository }}
|
|
|
|
short-description: ${{ github.event.repository.description }}
|
|
|
|
- name: DEBUG Show Runners environment
|
|
|
|
uses: nick-fields/retry@v2
|
|
|
|
with:
|
|
|
|
timeout_minutes: 5
|
|
|
|
max_attempts: 3
|
|
|
|
retry_wait_seconds: 120
|
|
|
|
command: |
|
|
|
|
export
|
|
|
|
- name: Identify GitHub Release tag name
|
|
|
|
# get tag name from runners environment 'GITHUB_REF_NAME' and then use bash substring
|
|
|
|
# to strip out '+' symbol - required due to gcr not supporting this as a tag
|
|
|
|
# name (docker hub does support it).
|
|
|
|
# note if push is NOT triggered by tag then 'GITHUB_REF_NAME' will be the branch name.
|
|
|
|
uses: nick-fields/retry@v2
|
|
|
|
with:
|
|
|
|
timeout_minutes: 5
|
|
|
|
max_attempts: 3
|
|
|
|
retry_wait_seconds: 120
|
|
|
|
command: |
|
|
|
|
tag="${GITHUB_REF_NAME}" && echo "tag=${tag//+/-}" >> $GITHUB_OUTPUT
|
|
|
|
echo "[debug] Generated tag name is '${tag}'"
|
|
|
|
echo "tag=$tag" >> $GITHUB_OUTPUT
|
|
|
|
id: identify_github_release_tag_name
|
|
|
|
- name: Generate temporary tag name
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
test_tag=$(date +%Y%m%d%H%M%S)
|
|
|
|
echo "[debug] Generated test tag name is '${test_tag}'"
|
|
|
|
echo "test_tag=$test_tag" >> $GITHUB_OUTPUT
|
|
|
|
id: generate_temporary_tag_name
|
|
|
|
- name: Generate app name
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
app_name=$(echo "${GITHUB_REPOSITORY}" | grep -P -o -m 1 '(?<=/arch-).*')
|
|
|
|
echo "[debug] Generated app name is '${app_name}'"
|
|
|
|
echo "app_name=$app_name" >> $GITHUB_OUTPUT
|
|
|
|
id: generate_app_name
|
|
|
|
- name: Build amd64 image and export to Docker for testing
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
load: true
|
|
|
|
tags: ghcr.io/${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }}
|
|
|
|
build-args: |
|
|
|
|
RELEASETAG=${{ steps.identify_github_release_tag_name.outputs.tag }}
|
|
|
|
- name: Run tests using previously built image
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
git_clone_scripts_dest="/tmp/scripts"
|
|
|
|
git_clone_scripts_repo="https://github.com/binhex/scripts.git"
|
|
|
|
git clone "${git_clone_scripts_repo}" "${git_clone_scripts_dest}"
|
|
|
|
"${git_clone_scripts_dest}/shell/arch/docker/testrunner.sh" --app-name ${{ steps.generate_app_name.outputs.app_name }} --image-name "ghcr.io/${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }}"
|
|
|
|
# note this will re-use the internal cached amd64 image from the previous build
|
|
|
|
- name: Build multi-arch Docker image, tag and push to registries
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
push: true
|
|
|
|
tags: ${{ github.repository }}:latest, ${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }}, quay.io/${{ github.repository }}:latest, quay.io/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }}, ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }}, registry.gitlab.com/${{ github.repository }}:latest, registry.gitlab.com/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }}
|
|
|
|
build-args: |
|
|
|
|
RELEASETAG=${{ steps.identify_github_release_tag_name.outputs.tag }}
|