mirror of
https://github.com/ChrispyBacon-dev/DockFlare.git
synced 2026-04-28 11:49:34 +00:00
failover to github runner in case selfhosted runner is unavailable
This commit is contained in:
parent
f8fb049559
commit
2d41b4ecf3
1 changed files with 60 additions and 8 deletions
68
.github/workflows/docker-image.yml
vendored
68
.github/workflows/docker-image.yml
vendored
|
|
@ -6,6 +6,7 @@ on:
|
|||
branches:
|
||||
- "stable" # For 'latest' and 'stable' tags
|
||||
- "unstable" # For 'unstable' tag
|
||||
- "dev" # For 'dev' tag
|
||||
tags:
|
||||
- "v*.*.*" # Trigger on semantic version tags like v1.2.3
|
||||
- "v*.*.*-*" # Trigger on pre-release semver tags like v1.2.3-beta.1
|
||||
|
|
@ -13,14 +14,17 @@ on:
|
|||
branches:
|
||||
- "stable"
|
||||
- "unstable"
|
||||
- "dev" # For pull requests on 'dev' branch
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Job 1: Attempt to build on your self-hosted runner
|
||||
build_self_hosted:
|
||||
runs-on: self-hosted
|
||||
|
||||
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
|
@ -47,18 +51,13 @@ jobs:
|
|||
with:
|
||||
images: alplat/dockflare
|
||||
tags: |
|
||||
# For Git tags like v1.2.3 -> image tag 1.2.3
|
||||
type=semver,pattern={{version}}
|
||||
# For Git tags like v1.2.3-beta.1 -> image tag 1.2.3-beta.1
|
||||
type=semver,pattern={{version}},suffix=-{{premajor}}-{{prerelease}}
|
||||
# For stable branch -> image tag 'latest' and 'stable'
|
||||
type=ref,event=branch,pattern=stable,value=latest
|
||||
type=ref,event=branch,pattern=stable,value=stable
|
||||
# For unstable branch -> image tag 'unstable'
|
||||
type=ref,event=branch,pattern=unstable,value=unstable
|
||||
# For all pushes, create a SHA tag
|
||||
type=ref,event=branch,pattern=dev,value=dev
|
||||
type=sha,format=short
|
||||
# Add a tag for the Git ref (branch name or tag name) itself
|
||||
type=ref,event=tag
|
||||
type=ref,event=branch
|
||||
|
||||
|
|
@ -71,3 +70,56 @@ jobs:
|
|||
push: ${{ github.event_name == 'push' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
# Job 2: This job only runs if the self-hosted build fails or is canceled
|
||||
build_github_hosted_fallback:
|
||||
|
||||
needs: build_self_hosted
|
||||
|
||||
if: failure() || cancelled()
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
if: github.event_name == 'push'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: alplat/dockflare
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{version}},suffix=-{{premajor}}-{{prerelease}}
|
||||
type=ref,event=branch,pattern=stable,value=latest
|
||||
type=ref,event=branch,pattern=stable,value=stable
|
||||
type=ref,event=branch,pattern=unstable,value=unstable
|
||||
type=ref,event=branch,pattern=dev,value=dev # Added for 'dev' branch
|
||||
type=sha,format=short
|
||||
type=ref,event=tag
|
||||
type=ref,event=branch
|
||||
|
||||
- name: Build and Push Docker Image
|
||||
id: build_and_push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./dockflare
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue