Build Docker Image #8
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@v2 | |
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/release-action@v1 | |
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/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker images | |
uses: docker/[email protected] | |
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/release-action@v1 | |
with: | |
allowUpdates: true | |
draft: false | |
tag: ${{ env.PKG_VERSION }} | |
name: ${{ env.PKG_VERSION }} | |
body: ${{ steps.changelog.outputs.changes }} | |
token: ${{ secrets.GITHUB_TOKEN }} |