Skip to content

Commit 9318a9f

Browse files
committed
feat: test posting comments
1 parent 1efdb65 commit 9318a9f

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

.github/workflows/pr-deploy-preview.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
name: Deploy preview for PR
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened]
6-
# branches: [main]
4+
push:
5+
branches:
6+
- main
77
# Allow manual runs from the Actions tab
88
workflow_dispatch:
99

1010
# Set permissions of the GITHUB_TOKEN
1111
permissions:
1212
contents: read
1313
id-token: write
14+
pull-requests: write
1415

1516
# Allow only one concurrent deployment
1617
concurrency:
1718
group: ${{ github.workflow }}-${{ github.ref }}
1819
cancel-in-progress: false
1920

21+
# Define environment variables
22+
env:
23+
HUGO_BASEURL: "https://preview-developer.espressif.com/pr${{ github.event.pull_request.number }}/"
24+
2025
# Default to bash
2126
defaults:
2227
run:
@@ -25,8 +30,6 @@ defaults:
2530
jobs:
2631
build-and-deploy-preview:
2732
runs-on: ubuntu-latest
28-
env:
29-
HUGO_BASEURL: "https://preview-developer.espressif.com/pr${{ github.event.pull_request.number }}/"
3033

3134
steps:
3235

@@ -71,11 +74,11 @@ jobs:
7174
github-token: ${{secrets.GITHUB_TOKEN}}
7275
script: |
7376
github.rest.issues.createComment({
77+
issue_number: context.issue.number,
7478
owner: context.repo.owner,
7579
repo: context.repo.repo,
76-
issue_number: context.payload.pull_request.number,
77-
body: `🎉 A preview of this PR is available at: [${process.env.HUGO_BASEURL}](${process.env.HUGO_BASEURL})`
78-
});
80+
body: `🎉 A preview of this PR is available at: ${{ env.HUGO_BASEURL }} `
81+
})
7982
8083
invalidate-cache:
8184
needs: build-and-deploy-preview
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
on:
2+
# Trigger the workflow on push or pull request
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
6+
jobs:
7+
comment:
8+
runs-on: ubuntu-latest
9+
env:
10+
HUGO_BASEURL: "https://preview-developer.espressif.com/pr${{ github.event.pull_request.number }}/"
11+
steps:
12+
- name: Post Preview Link to PR
13+
uses: actions/github-script@v7
14+
with:
15+
github-token: ${{secrets.GITHUB_TOKEN}}
16+
script: |
17+
github.rest.issues.createComment({
18+
issue_number: context.issue.number,
19+
owner: context.repo.owner,
20+
repo: context.repo.repo,
21+
body: `🎉 A preview of this PR is available at: [${{ env.HUGO_BASEURL }}](${{ env.HUGO_BASEURL }}) `
22+
})

0 commit comments

Comments
 (0)