Create logs-24-10-31.mdx #1
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: Netlify build manual deploy comment | |
on: | |
issue_comment: | |
types: [created] | |
pull_request: | |
types: [opened] | |
jobs: | |
deploy-preview: | |
# when a contributor comments 'netlify build', | |
# but only on pull requests, not issues. | |
# or if a contributor opens a PR for the first time. | |
if: | | |
(github.event.comment.body == 'netlify build' | |
&& github.event.issue.pull_request) | |
|| github.event.action == 'opened' | |
runs-on: ubuntu-latest | |
steps: | |
# we use `jq` to parse the GH API response | |
- name: setup jq | |
uses: dcarbone/install-jq-action@v2 | |
- name: send request to Netlify build hook | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh_api_url=$(echo ${{ github.event.issue.pull_request.url || github.event.pull_request.url }} | sed 's/https:\/\/api.github.com//') | |
gh_api_response=$(gh api $gh_api_url) | |
branch_name=$(echo $gh_api_response | jq -r .head.ref) | |
sha=$(echo $gh_api_response | jq -r .head.sha) | |
pr_number=$(echo $gh_api_response | jq -r .number) | |
curl -X POST \ | |
"https://api.netlify.com/build_hooks/${{ secrets.NETLIFY_BUILD_HOOK_ID }}?trigger_branch=$branch_name"'&trigger_title=Manual+deploy+preview+for+PR+%23'"$pr_number"'+-+'"$sha" | |
- name: comment for Netlify to update with preview URL | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
message: | | |
### <span aria-hidden="true">⏳</span> Netlify Preview Deployment Information | |
This comment will auto update when your preview build is ready | |
comment_tag: manual-build-comment |