-
Notifications
You must be signed in to change notification settings - Fork 5
fix X workflow trigger #138
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,20 +1,31 @@ | ||||||||||||||||||||||||||||||||||||||||||
| name: Post Release to X | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||
| release: | ||||||||||||||||||||||||||||||||||||||||||
| types: [published] | ||||||||||||||||||||||||||||||||||||||||||
| workflow_run: | ||||||||||||||||||||||||||||||||||||||||||
| workflows: ["Release"] | ||||||||||||||||||||||||||||||||||||||||||
| types: [completed] | ||||||||||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||
| notify: | ||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||
| - name: Get latest release | ||||||||||||||||||||||||||||||||||||||||||
| id: release | ||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||
| RELEASE=$(gh api /repos/${{ github.repository }}/releases/latest) | ||||||||||||||||||||||||||||||||||||||||||
| echo "tag=$(echo $RELEASE | jq -r .tag_name)" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||
| echo "url=$(echo $RELEASE | jq -r .html_url)" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Tweet new release | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+17
to
23
|
||||||||||||||||||||||||||||||||||||||||||
| RELEASE=$(gh api /repos/${{ github.repository }}/releases/latest) | |
| echo "tag=$(echo $RELEASE | jq -r .tag_name)" >> $GITHUB_OUTPUT | |
| echo "url=$(echo $RELEASE | jq -r .html_url)" >> $GITHUB_OUTPUT | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Tweet new release | |
| if ! RELEASE=$(gh api /repos/${{ github.repository }}/releases/latest 2>/dev/null); then | |
| echo "No GitHub release found; skipping notification." | |
| echo "tag=" >> "$GITHUB_OUTPUT" | |
| echo "url=" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "tag=$(echo "$RELEASE" | jq -r .tag_name)" >> "$GITHUB_OUTPUT" | |
| echo "url=$(echo "$RELEASE" | jq -r .html_url)" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Tweet new release | |
| if: ${{ steps.release.outputs.tag != '' }} |
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.
The conditional check will prevent this workflow from running when triggered via workflow_dispatch, since github.event.workflow_run will be null for manual triggers. Consider adding an additional condition to allow manual runs. For example:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}