Build Docker Image #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Docker Image | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
inputs: | |
publish: | |
description: 'Create Production Release' | |
required: true | |
type: boolean | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get Next Version | |
if: ${{ github.event.inputs.publish }} | |
id: semver | |
uses: ietf-tools/semver-action@v1 | |
with: | |
token: ${{ github.token }} | |
branch: main | |
- name: Set Next Version Env Var | |
if: ${{ github.event.inputs.publish }} | |
env: | |
NEXT_VERSION: ${{ steps.semver.outputs.next }} | |
run: | | |
echo "NEXT_VERSION=$next" >> $GITHUB_ENV | |
- name: Create Draft Release | |
uses: ncipollo/[email protected] | |
if: ${{ github.event.inputs.publish }} | |
with: | |
prerelease: true | |
draft: false | |
commit: ${{ github.sha }} | |
tag: ${{ env.NEXT_VERSION }} | |
name: ${{ env.NEXT_VERSION }} | |
body: '*pending*' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Build Variables | |
run: | | |
if [[ $NEXT_VERSION ]]; then | |
echo "Using AUTO SEMVER mode: $NEXT_VERSION" | |
echo "PKG_VERSION=$NEXT_VERSION" >> $GITHUB_ENV | |
echo "PKG_VERSION_STRICT=${NEXT_VERSION#?}" >> $GITHUB_ENV | |
else | |
echo "Using TAG mode: $GITHUB_REF_NAME" | |
echo "PKG_VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV | |
echo "PKG_VERSION_STRICT=${GITHUB_REF_NAME#?}" >> $GITHUB_ENV | |
fi | |
- name: Docker Login | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/ietf-tools/ietf-guides:latest | |
ghcr.io/ietf-tools/ietf-guides:${{ env.PKG_VERSION_STRICT }} | |
- name: Update CHANGELOG | |
id: changelog | |
uses: requarks/changelog-action@v1 | |
with: | |
token: ${{ github.token }} | |
tag: ${{ env.PKG_VERSION }} | |
writeToFile: false | |
- name: Create Release | |
uses: ncipollo/[email protected] | |
with: | |
allowUpdates: true | |
draft: false | |
tag: ${{ env.PKG_VERSION }} | |
name: ${{ env.PKG_VERSION }} | |
body: ${{ steps.changelog.outputs.changes }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
makeLatest: true |