-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🤖 Automatically create GH release after cnspec bump #271
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,62 @@ | ||
name: Create GitHub Release | ||
|
||
## Only trigger release when the VERSION file changed on main branch | ||
on: | ||
push: | ||
paths: | ||
- "VERSION" | ||
branches: | ||
- main | ||
|
||
jobs: | ||
create-gh-release: | ||
name: GH Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set release version | ||
run: echo "RELEASE_VERSION=$(cat VERSION)" >> $GITHUB_ENV | ||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: ${{ env.RELEASE_VERSION }} | ||
generate_release_notes: true | ||
make_latest: true | ||
token: ${{ secrets.PACKER_PLUGIN_DEPLOY_KEY_PRIV }} | ||
|
||
check-release: | ||
name: Check whether the release actually started | ||
runs-on: ubuntu-latest | ||
needs: create-gh-release | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set release version | ||
run: echo "RELEASE_VERSION=$(cat VERSION)" >> $GITHUB_ENV | ||
- name: Release file present? | ||
id: check_release_file | ||
uses: nick-fields/retry@v3 | ||
with: | ||
retry_wait_seconds: 10 | ||
timeout_seconds: 5 | ||
max_attempts: 60 | ||
retry_on: error | ||
# error on HTTP code different to 302 | ||
command: curl -o /dev/null -s -w "%{http_code}\n" "https://github.com/mondoohq/packer-plugin-cnspec/releases/download/${{ env.RELEASE_VERSION }}/packer-plugin-cnspec_${{ env.RELEASE_VERSION }}_SHA256SUMS" | grep 302 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find an easy way to query the workflow itself. When the workflow is done, we should have this file. |
||
- uses: sarisia/actions-status-discord@v1 | ||
if : ${{ always() && steps.check_release_file.outputs.status == 'failure' }} | ||
with: | ||
webhook: ${{ secrets.DISCORD_WEBHOOK }} | ||
benr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
status: ${{ steps.check_release_file.outputs.status }} | ||
url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
description: Workflow ${{ github.workflow }} for ${{ env.RELEASE_VERSION }} failed | ||
color: 0xff4d4d | ||
- uses: sarisia/actions-status-discord@v1 | ||
if : ${{ always() && steps.check_release_file.outputs.status == 'success' }} | ||
with: | ||
webhook: ${{ secrets.DISCORD_WEBHOOK }} | ||
status: ${{ steps.check_release_file.outputs.status }} | ||
url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
description: Workflow ${{ github.workflow }} for ${{ env.RELEASE_VERSION }} succeeded | ||
color: 0x5dea20 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a specific token to bypass GH limitations on the
GITHUB_TOKEN
to trigger subsequent workflow runs.