Skip to content

Commit 702103c

Browse files
authored
Next 2 (#747)
1 parent 1323c1a commit 702103c

2 files changed

Lines changed: 50 additions & 5 deletions

File tree

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

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
permissions:
2323
contents: read
2424
issues: write
25-
pull-requests: read
25+
pull-requests: write
2626

2727
env:
2828
DOCKER_BUILDKIT: 1
@@ -62,9 +62,54 @@ jobs:
6262

6363
- run: kamal deploy -d preview
6464

65+
- name: Comment preview URL on PR
66+
uses: actions/github-script@v7
67+
with:
68+
github-token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
69+
script: |
70+
const branch = '${{ github.ref_name }}';
71+
const previewUrl = 'https://${{ env.KAMAL_APP_DOMAIN }}';
72+
const body = `## Preview deployment ready\n\n**Preview URL:** [${previewUrl}](${previewUrl})`;
73+
74+
const { data: prs } = await github.rest.pulls.list({
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
state: 'open',
78+
head: `${context.repo.owner}:${branch}`
79+
});
80+
81+
if (prs.length === 0) return;
82+
83+
const issue_number = prs[0].number;
84+
const { data: comments } = await github.rest.issues.listComments({
85+
owner: context.repo.owner,
86+
repo: context.repo.repo,
87+
issue_number
88+
});
89+
90+
const previewComment = comments.find(
91+
c => c.user.type === 'Bot' && c.body.startsWith('## Preview deployment ready')
92+
);
93+
94+
if (previewComment) {
95+
await github.rest.issues.updateComment({
96+
owner: context.repo.owner,
97+
repo: context.repo.repo,
98+
comment_id: previewComment.id,
99+
body
100+
});
101+
} else {
102+
await github.rest.issues.createComment({
103+
owner: context.repo.owner,
104+
repo: context.repo.repo,
105+
issue_number,
106+
body
107+
});
108+
}
109+
65110
comment-preview-on-pr:
66111
runs-on: ubuntu-latest
67-
if: github.event_name == 'pull_request_target' && github.event.action != 'closed'
112+
if: github.event_name == 'pull_request_target'
68113
permissions:
69114
contents: read
70115
issues: write
@@ -88,9 +133,9 @@ jobs:
88133
- name: Comment preview URL on PR
89134
uses: actions/github-script@v7
90135
with:
91-
github-token: ${{ secrets.GITHUB_TOKEN }}
136+
github-token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
92137
script: |
93-
const previewUrl = 'https://website-${BRANCH_SLUG}.fairdataihub.org';
138+
const previewUrl = 'https://${{ env.KAMAL_APP_DOMAIN }}';
94139
const issue_number = context.payload.pull_request.number;
95140
96141
const body = `## Preview deployment ready\n\n**Preview URL:** [${previewUrl}](${previewUrl})`;

src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default function Home() {
9292
<div className="flex flex-col-reverse items-center justify-center md:flex-row">
9393
<div className="h-full w-full p-2 lg:max-w-2xl">
9494
<h2 className="text-left text-4xl font-extrabold text-stone-900 sm:text-4xl">
95-
The FAIR Data wave (next-1)
95+
The FAIR Data wave (next-21)
9696
</h2>
9797

9898
<div className="font-asap pt-8">

0 commit comments

Comments
 (0)