Skip to content

Commit

Permalink
Update image tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Trigus42 committed Oct 14, 2024
1 parent 8821e0e commit 9fae7e1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
51 changes: 37 additions & 14 deletions .github/actions/build-push-info/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ inputs:
docker_tag:
description: "docker tag"
required: false
commit_sha:
description: "Commit SHA the image is built from"
required: false

outputs:
qbt_release_tag:
Expand All @@ -20,12 +23,12 @@ outputs:
date:
description: "Current UTC date in YYYYMMDD format"
value: ${{ steps.env-info.outputs.date }}
short_sha:
description: "Short SHA of the current commit"
value: ${{ steps.env-info.outputs.short_sha }}
tags:
description: "Docker tags to publish"
value: ${{ steps.docker-tags.outputs.tags }}
build_sha_short:
description: "Short commit hash the image is built from"
value: ${{ steps.env-info.outputs.build_sha_short }}

runs:
using: "composite"
Expand All @@ -41,7 +44,14 @@ runs:
shell: bash
run: |
echo "date=$(date -u +%Y%m%d)" | tee -a $GITHUB_OUTPUT
echo "short_sha=$(git rev-parse --short HEAD)" | tee -a $GITHUB_OUTPUT
if [[ -n "${{ inputs.commit_sha }}" ]]; then
build_sha="${{ inputs.commit_sha }}"
else
build_sha=$(git rev-parse HEAD)
fi
echo "build_sha=$build_sha" | tee -a $GITHUB_OUTPUT
echo "build_sha_short=${build_sha:0:7}" | tee -a $GITHUB_OUTPUT
- name: Set up Docker Tags
id: docker-tags
Expand All @@ -50,22 +60,35 @@ runs:
GHCR_REPO="ghcr.io/trigus42/alpine-qbittorrentvpn"
DOCKERHUB_REPO="trigus42/qbittorrentvpn"
TAGS_NAMES=()
# Check if a tag is provided
if [[ -n "${{ inputs.docker_tag }}" ]]; then
TAGS_NAMES=(
${{ inputs.docker_tag }}
TAGS_NAMES+=(
"${{ inputs.docker_tag }}"
"${{ inputs.docker_tag }}-${{ steps.env-info.outputs.build_sha }}"
"${{ inputs.docker_tag }}-${{ steps.env-info.outputs.build_sha }}-qbt${{ steps.qbt-release.outputs.version_number }}"
)
elif [ "${{ github.ref_name }}" == "master" ]; then
TAGS_NAMES=(
"latest"
"qbt${{ steps.qbt-release.outputs.version_number }}"
"qbt${{ steps.qbt-release.outputs.version_number }}-${{ steps.env-info.outputs.date }}"
# Check if no custom commit SHA is provided
elif [[ -z "${{ inputs.commit_sha }}" ]]; then
# Master branch gets extra tags
if [[ "${{ github.ref_name }}" == "master" ]]; then
TAGS_NAMES+=(
"latest"
"qbt${{ steps.qbt-release.outputs.version_number }}"
"qbt${{ steps.qbt-release.outputs.version_number }}-${{ steps.env-info.outputs.date }}" # Legacy tag
)
fi
TAGS_NAMES+=(
"${{ github.head_ref || github.ref_name }}"
"${{ github.head_ref || github.ref_name }}-qbt${{ steps.qbt-release.outputs.version_number }}"
)
fi
TAGS_NAMES+=(
"${{ github.head_ref || github.ref_name }}"
"${{ github.sha }}"
"${{ github.sha }}-qbt${{ steps.qbt-release.outputs.version_number }}"
"${{ steps.env-info.outputs.build_sha }}"
"${{ steps.env-info.outputs.build_sha }}-qbt${{ steps.qbt-release.outputs.version_number }}"
)
# Prepare the tags for both repositories
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ on:
required: false
type: string
commit_sha:
description: 'Commit SHA to checkout. Requires docker_tag.'
description: 'Commit SHA to checkout'
required: false
type: string

Expand All @@ -50,8 +50,6 @@ jobs:
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.push }}" != "true" ]]; then
echo "Workflow was manually triggered, but push is disabled. Skipping push."
elif [[ -n "${{ inputs.commit_sha }}" && -z "${{ inputs.docker_tag }}" ]]; then
echo "commit_sha is set, but docker_tag isn't. Deploying specific commit to default tag is not allowed. Please provide a docker_tag."
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Pull request event detected. Skipping push."
else
Expand All @@ -67,6 +65,7 @@ jobs:
with:
qbt_tag: ${{ inputs.qbt_tag }}
docker_tag: ${{ inputs.docker_tag }}
commit_sha: ${{ inputs.commit_sha }}

- name: Setup Docker
uses: ./.github/actions/docker-setup
Expand Down Expand Up @@ -98,7 +97,7 @@ jobs:
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: ${{ steps.triggers.outputs.do_push == 'true' }}
build-args: |
"SOURCE_COMMIT=${{ steps.version_info.outputs.short_sha }}"
"SOURCE_COMMIT=${{ steps.version_info.outputs.build_sha_short }}"
"QBITTORRENT_TAG=${{ steps.version_info.outputs.qbt_release_tag }}"
tags: ${{ steps.version_info.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ docker compose up -d
|----------|----------|
| `trigus42/qbittorrentvpn:latest` | The latest image with the most recent version of qBittorrent |
| `trigus42/qbittorrentvpn:qbtx.x.x` | Image with qBittorrent version x.x.x |
| `trigus42/qbittorrentvpn:qbtx.x.x-YYYYMMDD` | Image built on YYYYMMDD with qBittorrent version x.x.x |
| `trigus42/qbittorrentvpn:COMMIT-HASH` | Image built from the commit with corresponding SHA hash |
| `trigus42/qbittorrentvpn:COMMIT-HASH-qbtx.x.x` | Image built from the commit with corresponding SHA hash and qBittorrent version x.x.x |
| `trigus42/qbittorrentvpn:BRANCH` | Image build from the corresponding branch |

WARNING: Only with the `latest` tag will you continuously receive updates.

Expand Down

0 comments on commit 9fae7e1

Please sign in to comment.