87 lines
2.7 KiB
YAML
87 lines
2.7 KiB
YAML
name: Manual Build for Dev or Feature Branches
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
branch:
|
|
description: 'Branch to build the Docker image from'
|
|
required: true
|
|
default: 'dev'
|
|
|
|
jobs:
|
|
manual-build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# Checkout the specified branch
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ github.event.inputs.branch }}
|
|
# Extract branch name and latest commit SHA
|
|
- name: Extract branch name and commit SHA
|
|
id: branch_info
|
|
run: |
|
|
echo "BRANCH_NAME=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
|
|
echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
|
|
|
# Create a file indicating this is a dev build
|
|
- name: Create DEV_BUILD file
|
|
run: |
|
|
echo "${{ env.BRANCH_NAME }}-${{ env.COMMIT_SHA }}" > DEV_BUILD
|
|
- name: Extract Version
|
|
id: extract_version
|
|
run: |
|
|
version=$(python3 -c "import version; print(f'{version.__version__}')")
|
|
echo "VERSION=$version" >> $GITHUB_ENV
|
|
|
|
- name: Read Changelog
|
|
id: changelog
|
|
run: |
|
|
if [ -f changelogs/${{ env.VERSION }}.md ]; then
|
|
changelog_content=$(cat changelogs/${{ env.VERSION }}.md)
|
|
echo "CHANGELOG_CONTENT<<EOF" >> $GITHUB_ENV
|
|
echo "$changelog_content" >> $GITHUB_ENV
|
|
echo "EOF" >> $GITHUB_ENV
|
|
else
|
|
echo "CHANGELOG_CONTENT=No changelog available for this release." >> $GITHUB_ENV
|
|
fi
|
|
|
|
# Set up Docker
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
# Log in to GHCR
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# Build and push Docker image to GHCR
|
|
- name: Build and Push Docker Image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: |
|
|
ghcr.io/${{ github.repository }}:${{ env.COMMIT_SHA }}
|
|
ghcr.io/${{ github.repository }}:${{ env.BRANCH_NAME }}
|
|
ghcr.io/${{ github.repository }}:${{ env.VERSION }}-${{ env.BRANCH_NAME}}
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: |
|
|
${{ env.VERSION }}-${{ env.BRANCH_NAME }}-${{ env.COMMIT_SHA }}
|
|
name: |
|
|
${{ env.BRANCH_NAME }} Release ${{ env.VERSION }}
|
|
body: |
|
|
${{ env.CHANGELOG_CONTENT }}
|
|
generate_release_notes: true
|
|
make_latest: false
|
|
|
|
|
|
|