Skip to content

Commit

Permalink
feat: update CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn Dirkse committed Jun 23, 2023
1 parent fe7d716 commit a570782
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 37 deletions.
76 changes: 41 additions & 35 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ on:
pull_request:
branches:
- main
- master
push:
branches:
- main
- master

jobs:
analyze-commits:
Expand Down Expand Up @@ -44,7 +42,6 @@ jobs:
release-tag: ${{ steps.next-version.outputs.release-tag }}
release-version: ${{ steps.next-version.outputs.release-version }}


docker:
uses: ./.github/workflows/docker-build-and-push-workflow.yml
needs: analyze-commits
Expand All @@ -53,26 +50,58 @@ jobs:
version: ${{ needs.analyze-commits.outputs.release-version }}
publish: >-
${{ (startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/master') &&
github.ref == 'refs/heads/main') &&
github.event_name == 'push' }}
docker-image-repo: ${{ vars.DOCKER_IMAGE_REPOSITORY }}
upload-sarif-to-security: >-
${{ (startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/master') &&
github.ref == 'refs/heads/main') &&
github.event_name == 'push' }}
release:
runs-on: ubuntu-latest
needs:
- docker
- analyze-commits
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
-
name: Update BuildInfo.properties if there is a version
run: /bin/bash .github/workflows/writeBuildInfo.sh ${{ needs.analyze-commits.outputs.release-version }}
-
name: "🔧 setup node"
uses: actions/setup-node@v2.1.5
with:
node-version: 18.x
-
name: Install dependencies
run: yarn global add semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github @semantic-release/exec @semantic-release/release-notes-generator @semantic-release/commit-analyzer conventional-changelog-conventionalcommits
-
name: Semantic Release
run: "semantic-release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-docker:
runs-on: ubuntu-latest
needs:
- docker
- release
- analyze-commits
if: >-
${{ (startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/master') &&
github.event_name == 'push' }}
(startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/main') &&
github.event_name == 'push' &&
needs.analyze-commits.outputs.release-version != '' &&
needs.analyze-commits.outputs.release-version != null
steps:
-
name: Show release version
run: echo "Pushing docker image for version ${{ needs.analyze-commits.outputs.release-version }}"
-
name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -100,26 +129,3 @@ jobs:
name: Push Docker image
run: docker push ${{ vars.DOCKER_IMAGE_REPOSITORY }} --all-tags

release:
runs-on: ubuntu-latest
needs: publish-docker
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
-
name: "🔧 setup node"
uses: actions/setup-node@v2.1.5
with:
node-version: 18.x
-
name: Install dependencies
run: yarn global add semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github @semantic-release/exec @semantic-release/release-notes-generator @semantic-release/commit-analyzer conventional-changelog-conventionalcommits
-
name: Semantic Release
run: "semantic-release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion .github/workflows/docker-build-and-push-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
type: boolean
required: false
description: Add latest flavor
default: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}
default: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
upload-sarif-to-security:
type: boolean
required: false
Expand All @@ -37,6 +37,9 @@ jobs:
-
name: Checkout
uses: actions/checkout@v3
-
name: Update BuildInfo.properties if there is a version
run: /bin/bash .github/workflows/writeBuildInfo.sh ${{ inputs.version }}
-
name: Extract Docker metadata
id: meta
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/writeBuildInfo.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/bin/bash

echo "version=$1" > src/main/configurations/LopendeZaken/BuildInfo.properties
if [[ -n $1 ]]; then
echo "writeBuildInfo.sh - writing version $1"
echo "version=$1" > src/main/configurations/LopendeZaken/BuildInfo.properties
echo "versionDate_ddmmyyyy=$(date +%d/%m/%Y)" >> src/main/configurations/LopendeZaken/BuildInfo.properties
else
echo "writeBuildInfo.sh - no version to write, leaving BuildInfo.properties unchanged"
fi

0 comments on commit a570782

Please sign in to comment.