-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NEW] Automated Workflows v1.12.0 Release
[GITOPS] - Merging 'release' in 'main' - Releasing into Production
- Loading branch information
Showing
7 changed files
with
195 additions
and
9 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
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,79 @@ | ||
#################################### | ||
## Delete Tags of Git Ops Events ## | ||
## Reusable Workflow ## | ||
#################################### | ||
|
||
# Delete Git Tags, acting as push events that trigger Git Ops Workflows | ||
|
||
name: Delete Git Ops Tags | ||
on: | ||
workflow_call: | ||
secrets: | ||
GH_PAT_CONTENT_RW: | ||
description: 'GitHub Personal Access Token with permission to Delete Tags; read/write permissions to Content' | ||
required: true | ||
jobs: | ||
delete_tags: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
# ref: ${{ github.head_ref }} | ||
token: ${{ secrets.GH_PAT_CONTENT_RW }} | ||
|
||
# DELETE 'release-me' tag, if found | ||
# if the tag exists on remote, then empty log message corresponds to successfull deletion | ||
- name: Delete the 'release-me' Tag, if found | ||
shell: bash | ||
run: | | ||
set -o pipefail | ||
git push origin -d release-me 2>&1 | tee tag-delete.log | ||
if [ -s tag-delete.log ]; then # file exists with >0 bytes content | ||
# if 2nd line of log message matches '[deleted] release-me', we are OK | ||
if [[ $(sed -n '2p' tag-delete.log) == *"[deleted] release-me"* ]]; then | ||
echo '- **Deleted Tag** `release-me` :)' >> $GITHUB_STEP_SUMMARY | ||
# if 1st line of log file is | ||
# error: unable to delete 'release-me': remote ref does not exist, we are OK | ||
elif [[ $(head -n 1 tag-delete.log) == *"error: unable to delete 'release-me': remote ref does not exist"* ]]; then | ||
echo '- **Tag** `release-me` **NOT Found on remote** :)' >> $GITHUB_STEP_SUMMARY | ||
else | ||
# we fail to anticipate log message, so we crash with ERROR | ||
echo '- [ERROR] Could not `Delete` or `Verify non-existing` **Tag** `release-me` on **remote** !' >> $GITHUB_STEP_SUMMARY | ||
echo "Error message:" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
echo "$(cat tag-delete.log)" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "**Exiting Job with ERROR !**" >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
fi | ||
else | ||
# no Log message captured, we exit with CRITICAL | ||
echo '- [CRITICAL] Could not capture Tag Deletion Log Message!' >> $GITHUB_STEP_SUMMARY | ||
echo "**Exiting Job with CRITICAL !**" >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
fi | ||
# DELETE any 'auto-prod-*' tag(s) found | ||
- name: Delete any auto-prod-* tag found | ||
env: | ||
auto_prod_prefix: 'auto-prod-' | ||
run: | | ||
# not possible to clobber existing tags, since local checkout only tracks default (ie main) branch | ||
# so we can safely fetch all tags | ||
git fetch --tags | ||
# Now we have guaranteed all local tags HAVE a remote counterpart (referencing the same commits) | ||
# iterate and delete each tag, if any deletion fails, we crash to indicate failure | ||
for git_tag in $(git tag -l "${auto_prod_prefix}*"); do | ||
git push origin --delete "${git_tag}" | ||
echo '- **Deleted Tag** ${git_tag}' >> $GITHUB_STEP_SUMMARY | ||
done |
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 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,36 @@ | ||
# Workflow go-delete-tags.yml | ||
|
||
### Trigger Events | ||
|
||
If any of the below events occur, the `go-delete-tags.yml` workflow will be triggered. | ||
|
||
- workflow_call | ||
|
||
Since there is a `workflow_call` _trigger_event_, this workflow can be triggered (called) by another (caller) workflow. | ||
> Thus, it is a `Reusable Workflow`. | ||
|
||
## Reusable Workflow | ||
|
||
Event Trigger: `workflow_call` | ||
|
||
### Inputs | ||
|
||
#### Required Inputs | ||
|
||
None | ||
|
||
#### Optional Inputs | ||
|
||
None | ||
|
||
### Secrets | ||
|
||
- `GH_PAT_CONTENT_RW` | ||
- type: _string_ | ||
- Required: True | ||
- Description: GitHub Personal Access Token with permission to Delete Tags; read/write permissions to Content | ||
|
||
### Outputs | ||
|
||
None |
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,44 @@ | ||
# Workflow go-tag-main.yml | ||
|
||
### Trigger Events | ||
|
||
If any of the below events occur, the `go-tag-main.yml` workflow will be triggered. | ||
|
||
- workflow_call | ||
|
||
Since there is a `workflow_call` _trigger_event_, this workflow can be triggered (called) by another (caller) workflow. | ||
> Thus, it is a `Reusable Workflow`. | ||
|
||
## Reusable Workflow | ||
|
||
Event Trigger: `workflow_call` | ||
|
||
### Inputs | ||
|
||
#### Required Inputs | ||
|
||
- `gh_email` | ||
- type: _string_ | ||
- Description: GitHub Email | ||
- `gh_username` | ||
- type: _string_ | ||
- Description: GitHub Username | ||
|
||
#### Optional Inputs | ||
|
||
- `main_branch` | ||
- type: _string_ | ||
- Description: Name of the Main Branch. Example: main, master | ||
- Default: `${{ github.event.pull_request.base.ref || vars.GIT_MAIN_BRANCH || 'main' }}` | ||
|
||
### Secrets | ||
|
||
- `GH_PAT_ACTION_RW` | ||
- type: _string_ | ||
- Required: True | ||
- Description: GitHub Personal Access Token with read/write permissions to Actions | ||
|
||
### Outputs | ||
|
||
None |
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 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