Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit db67a91

Browse files
authored
Merge pull request #6599 from matrix-org/dbkr/netlify_forked_pr_hack
Fix Netflify builds from fork PRs
2 parents 2e6da2d + 8016b34 commit db67a91

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

.github/workflows/layered-build.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,16 @@ jobs:
1616
path: element-web/webapp
1717
# We'll only use this in a triggered job, then we're done with it
1818
retention-days: 1
19+
- uses: actions/[email protected]
20+
with:
21+
script: |
22+
var fs = require('fs');
23+
fs.writeFileSync('${{github.workspace}}/pr.json', JSON.stringify(context.payload.pull_request));
24+
- name: Upload PR Info
25+
uses: actions/upload-artifact@v2
26+
with:
27+
name: pr.json
28+
path: pr.json
29+
# We'll only use this in a triggered job, then we're done with it
30+
retention-days: 1
1931

.github/workflows/netflify.yaml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,33 @@ jobs:
3333
});
3434
var fs = require('fs');
3535
fs.writeFileSync('${{github.workspace}}/previewbuild.zip', Buffer.from(download.data));
36-
- run: unzip previewbuild.zip && rm previewbuild.zip
36+
37+
var prInfoArtifact = artifacts.data.artifacts.filter((artifact) => {
38+
return artifact.name == "pr.json"
39+
})[0];
40+
var download = await github.actions.downloadArtifact({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
artifact_id: prInfoArtifact.id,
44+
archive_format: 'zip',
45+
});
46+
var fs = require('fs');
47+
fs.writeFileSync('${{github.workspace}}/pr.json.zip', Buffer.from(download.data));
48+
- name: Extract Artifacts
49+
run: unzip -d webapp previewbuild.zip && rm previewbuild.zip && unzip pr.json.zip && rm pr.json.zip
50+
- name: 'Read PR Info'
51+
id: readctx
52+
uses: actions/[email protected]
53+
with:
54+
script: |
55+
var fs = require('fs');
56+
var pr = JSON.parse(fs.readFileSync('${{github.workspace}}/pr.json'));
57+
console.log(`::set-output name=prnumber::${pr.number}`);
3758
- name: Deploy to Netlify
3859
id: netlify
3960
uses: nwtgck/[email protected]
4061
with:
41-
publish-dir: .
62+
publish-dir: webapp
4263
deploy-message: "Deploy from GitHub Actions"
4364
# These don't work because we're in workflow_run
4465
enable-pull-request-comment: false
@@ -51,7 +72,7 @@ jobs:
5172
uses: phulsechinmay/[email protected]
5273
with:
5374
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54-
ISSUE_ID: ${{ github.event.workflow_run.pull_requests[0].number }}
75+
ISSUE_ID: ${{ steps.readctx.outputs.prnumber }}
5576
message: |
5677
Preview: ${{ steps.netlify.outputs.deploy-url }}
5778
⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts.

0 commit comments

Comments
 (0)