-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1340 from SwanseaUniversityMedical/Development
ci/cd
- Loading branch information
Showing
5 changed files
with
205 additions
and
82 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
name: Build and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
env: | ||
HARBOR_REGISTRY: ${{ vars.HARBOR_REGISTRY }} | ||
HARBOR_PROJECT: ${{ vars.HARBOR_PROJECT }} | ||
HARBOR_REPO: ${{ vars.HARBOR_REPO }} | ||
HARBOR_USER: ${{ vars.HARBOR_USER }} | ||
HARBOR_TOKEN: ${{ secrets.HARBOR_TOKEN }} | ||
|
||
jobs: | ||
release-container: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
TAG_PREFIX: 'Concept-Library' | ||
TAG_FORMAT: 'Concept-Library-${version}' | ||
|
||
steps: | ||
- name: clone repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: build container | ||
run: | | ||
docker build -t image -f "Dockerfile" . | ||
- name: registry login | ||
run: | | ||
echo "$HARBOR_TOKEN" | docker login $HARBOR_REGISTRY -u $HARBOR_USER --password-stdin | ||
- name: generate token | ||
id: generate-token | ||
uses: tibdex/[email protected] | ||
with: | ||
app_id: ${{ vars.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
- name: semantic release dry run | ||
uses: docker://ghcr.io/codfish/semantic-release-action:v2 | ||
id: semantic-dry | ||
with: | ||
dry_run: true | ||
|
||
branches: | | ||
[ | ||
'+([0-9])?(.{+([0-9]),x}).x', | ||
'master' | ||
] | ||
tag_format: ${{ env.TAG_FORMAT }} | ||
|
||
plugins: |- | ||
[ | ||
['@semantic-release/commit-analyzer', { | ||
"releaseRules": [ | ||
{"type": "major", "release": "major"}, | ||
{"type": "minor", "release": "minor"}, | ||
{"type": "patch", "release": "patch"}, | ||
{"type": "no-release", "release": false}, | ||
{"type": "chore", "release": "patch"}, | ||
{"type": "refactor", "release": "patch"}, | ||
{"type": "style", "release": "patch"}, | ||
{"type": "docs", "release": false}, | ||
{"type": "test", "release": false}, | ||
{"type": "ci", "release": false}, | ||
{"type": "feat", "release": "minor"}, | ||
{"type": "revert", "release": "patch"}, | ||
{"type": "perf", "release": "patch"}, | ||
{"type": "fix", "release": "patch"}, | ||
{"type": "build", "release": "patch"}, | ||
], | ||
}] | ||
] | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | ||
|
||
- name: semantic release | ||
if: steps.semantic-dry.outputs.new-release-published == 'true' | ||
uses: docker://ghcr.io/codfish/semantic-release-action:v2 | ||
id: semantic | ||
with: | ||
branches: | | ||
[ | ||
'+([0-9])?(.{+([0-9]),x}).x', | ||
'master' | ||
] | ||
tag_format: ${{ env.TAG_FORMAT }} | ||
|
||
additional_packages: | | ||
['@semantic-release/exec'] | ||
plugins: |- | ||
[ | ||
['@semantic-release/commit-analyzer', { | ||
"releaseRules": [ | ||
{"type": "major", "release": "major"}, | ||
{"type": "minor", "release": "minor"}, | ||
{"type": "patch", "release": "patch"}, | ||
{"type": "no-release", "release": false}, | ||
{"type": "chore", "release": "patch"}, | ||
{"type": "refactor", "release": "patch"}, | ||
{"type": "style", "release": "patch"}, | ||
{"type": "docs", "release": false}, | ||
{"type": "test", "release": false}, | ||
{"type": "ci", "release": false}, | ||
{"type": "feat", "release": "minor"}, | ||
{"type": "revert", "release": "patch"}, | ||
{"type": "perf", "release": "patch"}, | ||
{"type": "fix", "release": "patch"}, | ||
{"type": "build", "release": "patch"}, | ||
], | ||
}], | ||
['@semantic-release/exec', { | ||
"generateNotesCmd": "echo '${ process.env.RELEASE_NOTES }'" | ||
}], | ||
'@semantic-release/release-notes-generator', | ||
['@semantic-release/github', { | ||
"successComment": false, | ||
"failTitle": false | ||
}] | ||
] | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | ||
RELEASE_NOTES: | | ||
``` | ||
echo "<token>" | docker login ${{ env.HARBOR_REGISTRY }} -u <username> --password-stdin | ||
docker pull ${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.HARBOR_REPO }}:${{ steps.semantic-dry.outputs.release-version }} | ||
``` | ||
- name: container push to registry | ||
id: container-push | ||
if: steps.semantic.outputs.new-release-published == 'true' | ||
run: | | ||
docker tag image $HARBOR_REGISTRY/$HARBOR_PROJECT/$HARBOR_REPO:$TAG | ||
docker push $HARBOR_REGISTRY/$HARBOR_PROJECT/$HARBOR_REPO:$TAG | ||
env: | ||
TAG: ${{ steps.semantic.outputs.release-version }} | ||
|
||
- name: delete orphaned release on container push failure | ||
uses: dev-drprasad/[email protected] | ||
if: (failure() && steps.container-push.outcome == 'failure') && steps.semantic.outputs.new-release-published == 'true' | ||
with: | ||
tag_name: ${ env.TAG_PREFIX }-${{ steps.semantic.outputs.release-version }} | ||
delete_release: true | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} |
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
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.