Loom to slack #10320
Workflow file for this run
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: Loom to slack | |
on: | |
workflow_call: # Enable workflow reuse/import | |
pull_request_review: | |
types: | |
- submitted | |
pull_request: | |
types: | |
- closed | |
jobs: | |
search: | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs | |
outputs: | |
link: ${{ env.LOOM_LINK }} | |
steps: | |
- name: Fetch first post | |
run: gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} | tee ./FIRST_POST | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable | |
- name: Find loom | |
run: | | |
REGEX="https://\(www\.\)\?loom\.com/share/\w\{32\}" | |
grep $REGEX ./FIRST_POST --max-count 1 --only-matching | tee ./LOOM_LINK || true | |
echo "LOOM_LINK=$(cat LOOM_LINK)" >> $GITHUB_ENV | |
reminder: | |
needs: search | |
if: github.event.review.state == 'approved' && github.event.pull_request.user.login != 'dependabot[bot]' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get PR status | |
run: | | |
STATUS=$( | |
gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json state --jq .state | |
) | |
echo STATUS=$STATUS >> $GITHUB_ENV | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Post loom if present | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ needs.search.outputs.link && env.STATUS == 'OPEN' }} | |
with: | |
message: | | |
When the PR is merged, the [first loom link found on this PR](${{ needs.search.outputs.link }}) will be posted to `#sprint-demo` on Slack. _Do not edit this comment manually._ | |
- name: Remind to post loom if missing | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ ! needs.search.outputs.link && env.STATUS == 'OPEN' }} | |
with: | |
message: | | |
No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack. | |
_Do not edit this comment manually._ | |
slack: | |
needs: search | |
if: github.event.pull_request.merged && needs.search.outputs.link | |
runs-on: ubuntu-latest | |
steps: | |
- uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_CHANNEL: sprint-demo | |
SLACK_MESSAGE: | | |
*${{ github.event.pull_request.title }}* | |
<${{ github.event.pull_request.html_url }}|Pull request #${{ github.event.pull_request.number }}> | |
<${{ needs.search.outputs.link }}|Demo video> | |
SLACK_FOOTER: 🚀 | |
MSG_MINIMAL: true |