Skip to content

Commit 1323c1a

Browse files
authored
chore: test pr (#744)
1 parent d9a0fdd commit 1323c1a

3 files changed

Lines changed: 56 additions & 45 deletions

File tree

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

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ on:
1111
- next
1212
pull_request:
1313
types: [closed]
14-
branches-ignore:
15-
- main
16-
- next
14+
pull_request_target:
15+
types: [opened, reopened, synchronize]
1716
delete:
1817

1918
jobs:
@@ -31,9 +30,8 @@ jobs:
3130
KAMAL_REGISTRY_USERNAME: ${{ secrets.KAMAL_REGISTRY_USERNAME }}
3231
KAMAL_REGISTRY_PASSWORD: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}
3332
KAMAL_SERVER_IP: ${{ secrets.KAMAL_SERVER_IP }}
34-
KAMAL_APP_NAME: ${{ secrets.KAMAL_APP_NAME }}
35-
KAMAL_APP_DOMAIN: ${{ secrets.KAMAL_APP_DOMAIN }}
36-
33+
KAMAL_APP_NAME: "fairdataihub-website"
34+
KAMAL_APP_DOMAIN: "next.fairdataihub.org"
3735
steps:
3836
- uses: actions/checkout@v4
3937

@@ -45,8 +43,8 @@ jobs:
4543
| sed 's/-\+/-/g' \
4644
| sed 's/^-//;s/-$//')
4745
48-
APP_NAME="${{ secrets.KAMAL_APP_NAME }}-${BRANCH_SLUG}"
49-
APP_DOMAIN="${APP_NAME}.${{ secrets.KAMAL_APP_DOMAIN }}"
46+
APP_NAME="fairdataihub-website-${BRANCH_SLUG}"
47+
APP_DOMAIN="website-${BRANCH_SLUG}.fairdataihub.org"
5048
5149
echo "KAMAL_APP_NAME=${APP_NAME}" >> "$GITHUB_ENV"
5250
echo "KAMAL_APP_DOMAIN=${APP_DOMAIN}" >> "$GITHUB_ENV"
@@ -64,50 +62,63 @@ jobs:
6462

6563
- run: kamal deploy -d preview
6664

65+
comment-preview-on-pr:
66+
runs-on: ubuntu-latest
67+
if: github.event_name == 'pull_request_target' && github.event.action != 'closed'
68+
permissions:
69+
contents: read
70+
issues: write
71+
pull-requests: write
72+
73+
steps:
74+
- name: Set preview app name and domain
75+
run: |
76+
BRANCH_SLUG=$(echo "${{ github.event.pull_request.head.ref }}" \
77+
| tr '[:upper:]' '[:lower:]' \
78+
| sed 's/[^a-z0-9-]/-/g' \
79+
| sed 's/-\+/-/g' \
80+
| sed 's/^-//;s/-$//')
81+
82+
APP_NAME="fairdataihub-website-${BRANCH_SLUG}"
83+
APP_DOMAIN="website-${BRANCH_SLUG}.fairdataihub.org"
84+
85+
echo "KAMAL_APP_NAME=${APP_NAME}" >> "$GITHUB_ENV"
86+
echo "KAMAL_APP_DOMAIN=${APP_DOMAIN}" >> "$GITHUB_ENV"
87+
6788
- name: Comment preview URL on PR
68-
if: success()
6989
uses: actions/github-script@v7
7090
with:
7191
github-token: ${{ secrets.GITHUB_TOKEN }}
7292
script: |
73-
const branch = '${{ github.ref_name }}';
74-
const previewUrl = 'https://${{ env.KAMAL_APP_DOMAIN }}';
93+
const previewUrl = 'https://website-${BRANCH_SLUG}.fairdataihub.org';
94+
const issue_number = context.payload.pull_request.number;
7595
76-
const { data: prs } = await github.rest.pulls.list({
96+
const body = `## Preview deployment ready\n\n**Preview URL:** [${previewUrl}](${previewUrl})`;
97+
98+
const { data: comments } = await github.rest.issues.listComments({
7799
owner: context.repo.owner,
78100
repo: context.repo.repo,
79-
state: 'open',
80-
head: `${context.repo.owner}:${branch}`
101+
issue_number
81102
});
82103
83-
const body = `## Preview deployment ready\n\n**Preview URL:** [${previewUrl}](${previewUrl})`;
104+
const previewComment = comments.find(
105+
c => c.user.type === 'Bot' && c.body.startsWith('## Preview deployment ready')
106+
);
84107
85-
for (const pr of prs) {
86-
const { data: comments } = await github.rest.issues.listComments({
108+
if (previewComment) {
109+
await github.rest.issues.updateComment({
87110
owner: context.repo.owner,
88111
repo: context.repo.repo,
89-
issue_number: pr.number
112+
comment_id: previewComment.id,
113+
body
114+
});
115+
} else {
116+
await github.rest.issues.createComment({
117+
owner: context.repo.owner,
118+
repo: context.repo.repo,
119+
issue_number,
120+
body
90121
});
91-
92-
const previewComment = comments.find(
93-
c => c.user.type === 'Bot' && c.body.startsWith('## Preview deployment ready')
94-
);
95-
96-
if (previewComment) {
97-
await github.rest.issues.updateComment({
98-
owner: context.repo.owner,
99-
repo: context.repo.repo,
100-
comment_id: previewComment.id,
101-
body
102-
});
103-
} else {
104-
await github.rest.issues.createComment({
105-
owner: context.repo.owner,
106-
repo: context.repo.repo,
107-
issue_number: pr.number,
108-
body
109-
});
110-
}
111122
}
112123
113124
remove-preview:
@@ -130,8 +141,8 @@ jobs:
130141
KAMAL_REGISTRY_USERNAME: ${{ secrets.KAMAL_REGISTRY_USERNAME }}
131142
KAMAL_REGISTRY_PASSWORD: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}
132143
KAMAL_SERVER_IP: ${{ secrets.KAMAL_SERVER_IP }}
133-
KAMAL_APP_NAME: ${{ secrets.KAMAL_APP_NAME }}
134-
KAMAL_APP_DOMAIN: ${{ secrets.KAMAL_APP_DOMAIN }}
144+
KAMAL_APP_NAME: "fairdataihub-website"
145+
KAMAL_APP_DOMAIN: "next.fairdataihub.org"
135146

136147
steps:
137148
- uses: actions/checkout@v4
@@ -154,8 +165,8 @@ jobs:
154165
| sed 's/-\+/-/g' \
155166
| sed 's/^-//;s/-$//')
156167
157-
APP_NAME="${{ secrets.KAMAL_APP_NAME }}-${BRANCH_SLUG}"
158-
APP_DOMAIN="${APP_NAME}.${{ secrets.KAMAL_APP_DOMAIN }}"
168+
APP_NAME="fairdataihub-website-${BRANCH_SLUG}"
169+
APP_DOMAIN="website-${BRANCH_SLUG}.fairdataihub.org"
159170
160171
echo "KAMAL_APP_NAME=${APP_NAME}" >> "$GITHUB_ENV"
161172
echo "KAMAL_APP_DOMAIN=${APP_DOMAIN}" >> "$GITHUB_ENV"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"reset": "rm -rf node_modules .next && yarn install"
3333
},
3434
"lint-staged": {
35-
"./src/**/*.{ts,js,jsx,tsx}": [
35+
"./src/**/*.{mx}": [
3636
"yarn lint --fix",
3737
"yarn format"
3838
]
@@ -164,4 +164,4 @@
164164
"node": "22.18.0",
165165
"yarn": "1.22.22"
166166
}
167-
}
167+
}

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
95+
The FAIR Data wave (next-1)
9696
</h2>
9797

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

0 commit comments

Comments
 (0)