-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update GHA to publish documentation updates and tag repo (#20)
- Loading branch information
1 parent
d80e8a8
commit 392abd4
Showing
1 changed file
with
92 additions
and
2 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 |
---|---|---|
|
@@ -6,9 +6,12 @@ name: Publish Docs Workflow | |
on: | ||
push: | ||
branches: | ||
- master | ||
- master | ||
workflow_dispatch: | ||
|
||
env: | ||
REPO_OWNER: "omec-project" | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
|
@@ -28,8 +31,95 @@ jobs: | |
echo "$files" | ||
fi | ||
# NOTE: Action to tag repo, publish images/documents only enabled for "omec-project" | ||
# CAUTION: Other actions depend on this name "tag-github" | ||
tag-github: | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == env.REPO_OWNER | ||
outputs: | ||
changed: ${{ steps.version-change.outputs.changed }} | ||
version: ${{ steps.version-change.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get changes | ||
id: version-file | ||
run: | | ||
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep VERSION; then | ||
echo "changed=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "VERSION file was not changed" | ||
fi | ||
- name: Validate change in version file | ||
id: version-change | ||
if: steps.version-file.outputs.changed == 'true' | ||
run: | | ||
version=$(cat VERSION) | ||
echo "version=$version" | ||
validate="^[0-9]+\.[0-9]+\.[0-9]+$" | ||
if [[ $version =~ $validate ]]; then | ||
echo "changed=true" >> $GITHUB_OUTPUT | ||
echo "version=$version" >> $GITHUB_OUTPUT | ||
else | ||
echo "Version change not for release" | ||
fi | ||
- name: Create release using REST API | ||
if: steps.version-change.outputs.changed == 'true' | ||
run: | | ||
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GH_OMEC_PAT }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/${{ github.repository }}/releases \ | ||
-d '{ | ||
"tag_name": "v${{ steps.version-change.outputs.version }}", | ||
"target_commitish": "${{ github.event.repository.default_branch }}", | ||
"name": "v${{ steps.version-change.outputs.version }}", | ||
"draft": false, | ||
"prerelease": false, | ||
"generate_release_notes": true | ||
}' | ||
update-version: | ||
runs-on: ubuntu-latest | ||
needs: tag-github | ||
if: needs.tag-github.outputs.changed == 'true' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Increment version | ||
run: | | ||
version=${{ needs.tag-github.outputs.version }} | ||
IFS='.' read -r major minor patch <<< "$version" | ||
minor_update=$((minor+1)) | ||
NEW_VERSION="$major.$minor_update.$patch-dev" | ||
echo $NEW_VERSION > VERSION | ||
echo "Updated version: $NEW_VERSION" | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GH_OMEC_PAT }} | ||
commit-message: Update version | ||
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | ||
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> | ||
signoff: false | ||
branch: version-update | ||
delete-branch: true | ||
title: Update version | ||
body: | | ||
Update VERSION file | ||
add-paths: | | ||
VERSION | ||
publish: | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == env.REPO_OWNER | ||
env: | ||
BUILD_OUTPUT_PATH: _build/multiversion/ | ||
steps: | ||
|
@@ -42,7 +132,7 @@ jobs: | |
run: ls $BUILD_OUTPUT_PATH* | ||
|
||
- name: rsync deployments | ||
uses: burnett01/[email protected].0 | ||
uses: burnett01/[email protected].1 | ||
with: | ||
switches: -rvzh --delete-after --exclude=.git | ||
path: $BUILD_OUTPUT_PATH | ||
|