Add emoji reactions to release PR requests #36
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
name: Release PR | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
release_check: | |
if: github.repository == 'replayio/replay-cli' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/release-pr') | |
runs-on: ubuntu-latest | |
steps: | |
- id: report_in_progress | |
run: | | |
echo "in_progress_reaction_id=$(gh api /repos/${{github.repository}}/issues/comments/${{github.event.comment.id}}/reactions -f content='eyes' --jq '.id')" >> "$GITHUB_OUTPUT" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- id: check_authorization | |
run: | | |
if [[ $AUTHOR_ASSOCIATION == 'MEMBER' || $AUTHOR_ASSOCIATION == 'OWNER' ]] | |
then | |
echo "User is authorized to release" | |
else | |
echo "User is not authorized to release" | |
exit 1 | |
fi | |
env: | |
AUTHOR_ASSOCIATION: ${{ github.event.comment.author_association }} | |
outputs: | |
in_progress_reaction_id: ${{ steps.report_in_progress.outputs.in_progress_reaction_id }} | |
release: | |
if: github.repository == 'replayio/replay-cli' | |
timeout-minutes: 20 | |
runs-on: ubuntu-latest | |
needs: release_check | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Checkout pull request | |
run: gh pr checkout ${{ github.event.issue.number }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check if Version Packages PR | |
id: check_version_packages | |
run: | | |
echo "version_packages=$(gh pr view ${{ github.event.issue.number }} --json headRefName --jq '.headRefName|startswith("changeset-release/")')" >> "$GITHUB_OUTPUT" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Reset Version Packages PR | |
if: steps.check_version_packages.outputs.version_packages == 'true' | |
run: git reset --hard HEAD~1 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
cache: "yarn" | |
- run: yarn --immutable | |
- run: yarn run bootstrap | |
- name: Set up NPM token | |
run: | | |
echo "npmAuthToken: $NPM_TOKEN" >> .yarnrc.yml | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- run: yarn changeset version --snapshot pr${{ github.event.issue.number }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: yarn build | |
- name: Release snapshot versions | |
run: yarn run release:pr --tag pr${{ github.event.issue.number }} | |
- run: gh api /repos/${{github.repository}}/issues/comments/${{github.event.comment.id}}/reactions -f content='rocket' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: gh api -X DELETE /repos/${{github.repository}}/issues/comments/${{github.event.comment.id}}/reactions/${{needs.release_check.outputs.in_progress_reaction_id}} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
report-failure-if-needed: | |
needs: [release_check, release] | |
timeout-minutes: 2 | |
runs-on: ubuntu-latest | |
if: failure() && github.repository == 'replayio/replay-cli' && (needs.release_check.result == 'failure' || needs.release.result == 'failure') | |
steps: | |
- run: gh api /repos/${{github.repository}}/issues/comments/${{github.event.comment.id}}/reactions -f content='-1' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: gh api -X DELETE /repos/${{github.repository}}/issues/comments/${{github.event.comment.id}}/reactions/${{needs.release_check.outputs.in_progress_reaction_id}} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |