Skip to content

Commit

Permalink
workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
g1ibby committed Dec 16, 2024
1 parent 5e56a4b commit a925517
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
30 changes: 25 additions & 5 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Docker Build and Publish

on:
push:
branches: [ "main" ]
Expand All @@ -20,10 +19,27 @@ jobs:
contents: read
packages: write
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

# Get version from git tag or generate from commit
- name: Get version
id: version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
# If this is a tag push, use the tag name as version
VERSION=${GITHUB_REF#refs/tags/v}
else
# If this is a branch push, use commit sha and branch name
SHA=$(git rev-parse --short HEAD)
BRANCH=${GITHUB_REF#refs/heads/}
VERSION="${BRANCH}-${SHA}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -45,11 +61,13 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha,format=long
- name: Build and push Docker image
uses: docker/build-push-action@v5
Expand All @@ -58,5 +76,7 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
6 changes: 2 additions & 4 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/

name: Fly Deploy
# on:
# push:
# branches:
# - main
workflow_dispatch:

jobs:
deploy:
name: Deploy app
Expand Down
29 changes: 25 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
name: Create Release
on:
# Manual trigger with version choice
workflow_dispatch:
inputs:
version_type:
description: 'Version type (major/minor/patch)'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major

# Automatic trigger on push to main
push:
branches: [ "main" ]
branches:
- main
paths-ignore:
- '**.md'
- '.gitignore'
Expand All @@ -23,14 +38,20 @@ jobs:
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
continue-on-error: true

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: patch
release_branches: main
# Use manual input if workflow_dispatch, otherwise determine from commit messages
default_bump: ${{ github.event.inputs.version_type || 'patch' }}
# Configure commit messages that trigger version bumps
major_string: "BREAKING CHANGE:"
minor_string: "feat:"
patch_string: "fix:"
# Optional: prefix for tag
tag_prefix: "v"

- name: Create Release
uses: softprops/action-gh-release@v1
Expand Down

0 comments on commit a925517

Please sign in to comment.