cd changed, #minor #13
Workflow file for this run
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: CD | |
on: | |
# Publish on every approved PR | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: write | |
packages: write | |
env: | |
TEST_TAG: ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKERHUB_REPO }}:22.04-v0.32.0-d76db35 | |
LATEST_TAG: ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKERHUB_REPO }}:latest | |
jobs: | |
check: | |
name: check pr status | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: check if PR is merged | |
uses: zmynx/github-actions/.github/actions/git/check-merge@feature/gha | |
cd: | |
name: continuous-deployment | |
needs: [check] | |
runs-on: ubuntu-22.04 | |
outputs: | |
new_tag: ${{ steps.semver.outputs.new_tag }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
fetch-depth: 0 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build locally | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: Dockerfile.ubuntu | |
platforms: linux/amd64 | |
push: false | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Generate Release using Docker | |
run: | | |
docker run \ | |
--interactive \ | |
--rm \ | |
--volume ./project-demo:/project \ | |
${{ env.TEST_TAG }} \ | |
ceedling release | |
- name: Semantic Versioning | |
id: semverv2 | |
uses: zmynx/github-actions/.github/actions/semver-v2@feature/gha | |
with: | |
fallback: "0.1.0" | |
prefix: "v" | |
- name: Downcase PR body | |
id: downcase | |
shell: bash | |
env: | |
PR_BODY: ${{ github.event.pull_request.body }} | |
run: echo "pr_body_lowercase=${PR_BODY,,}" >> $GITHUB_OUTPUT | |
- name: Parse the body for any '#major' or '#minor' keywords | |
id: new_tag | |
shell: bash | |
env: | |
NEW_TAG: ${{ contains(steps.downcase.outputs.pr_body_lowercase, '#major') && steps.semverv2.outputs.major || contains(steps.downcase.outputs.pr_body_lowercase, '#minor') && steps.semverv2.outputs.minor || steps.semverv2.outputs.patch }} | |
run: echo "new_tag=${NEW_TAG}" >> $GITHUB_OUTPUT | |
- name: Publish GitHub Release | |
uses: softprops/[email protected] | |
with: | |
files: /project-demo/build/artifacts/release/MyApp.out | |
tag_name: ${{ steps.new_tag.outputs.new_tag }} | |
- name: Git Config | |
uses: zmynx/github-actions/.github/actions/git/git-config@feature/gha | |
- name: Git Tag | |
uses: zmynx/github-actions/.github/actions/git/git-tag@feature/gha | |
with: | |
tag: "${{ format('{0}{1}', 'v', steps.new_tag.outputs.new_tag) }}" | |
- name: Publish image to DockerHub | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: Dockerfile.ubuntu | |
platforms: linux/amd64 | |
push: true | |
tags: | | |
${{ vars.DOCKERHUB_REPO }}:${{ steps.new_tag.outputs.new_tag }} | |
${{ vars.DOCKERHUB_REPO }}:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |