Use PR number directly in netlify github action (#7561)
* Use PR number directly in netlify github action Looks like we can get the PR number for the workflow run that triggered the workflow_run event, so there's no need for the massive faff we were doing here. * No need to create pr.json anymore
This commit is contained in:
parent
f217c6fd61
commit
a2f09480ee
2 changed files with 2 additions and 34 deletions
12
.github/workflows/layered-build.yaml
vendored
12
.github/workflows/layered-build.yaml
vendored
|
@ -17,16 +17,4 @@ jobs:
|
||||||
path: element-web/webapp
|
path: element-web/webapp
|
||||||
# We'll only use this in a triggered job, then we're done with it
|
# We'll only use this in a triggered job, then we're done with it
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
- uses: actions/github-script@v3.1.0
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
var fs = require('fs');
|
|
||||||
fs.writeFileSync('${{github.workspace}}/pr.json', JSON.stringify(context.payload.pull_request));
|
|
||||||
- name: Upload PR Info
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: pr.json
|
|
||||||
path: pr.json
|
|
||||||
# We'll only use this in a triggered job, then we're done with it
|
|
||||||
retention-days: 1
|
|
||||||
|
|
||||||
|
|
24
.github/workflows/netlify.yaml
vendored
24
.github/workflows/netlify.yaml
vendored
|
@ -33,28 +33,8 @@ jobs:
|
||||||
});
|
});
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
fs.writeFileSync('${{github.workspace}}/previewbuild.zip', Buffer.from(download.data));
|
fs.writeFileSync('${{github.workspace}}/previewbuild.zip', Buffer.from(download.data));
|
||||||
|
|
||||||
var prInfoArtifact = artifacts.data.artifacts.filter((artifact) => {
|
|
||||||
return artifact.name == "pr.json"
|
|
||||||
})[0];
|
|
||||||
var download = await github.actions.downloadArtifact({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
artifact_id: prInfoArtifact.id,
|
|
||||||
archive_format: 'zip',
|
|
||||||
});
|
|
||||||
var fs = require('fs');
|
|
||||||
fs.writeFileSync('${{github.workspace}}/pr.json.zip', Buffer.from(download.data));
|
|
||||||
- name: Extract Artifacts
|
- name: Extract Artifacts
|
||||||
run: unzip -d webapp previewbuild.zip && rm previewbuild.zip && unzip pr.json.zip && rm pr.json.zip
|
run: unzip -d webapp previewbuild.zip && rm previewbuild.zip
|
||||||
- name: 'Read PR Info'
|
|
||||||
id: readctx
|
|
||||||
uses: actions/github-script@v3.1.0
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
var fs = require('fs');
|
|
||||||
var pr = JSON.parse(fs.readFileSync('${{github.workspace}}/pr.json'));
|
|
||||||
console.log(`::set-output name=prnumber::${pr.number}`);
|
|
||||||
- name: Deploy to Netlify
|
- name: Deploy to Netlify
|
||||||
id: netlify
|
id: netlify
|
||||||
uses: nwtgck/actions-netlify@v1.2
|
uses: nwtgck/actions-netlify@v1.2
|
||||||
|
@ -73,7 +53,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
pull-request-number: ${{ steps.readctx.outputs.prnumber }}
|
pull-request-number: ${{github.event.workflow_run.pull_requests[0].number}}
|
||||||
description-message: |
|
description-message: |
|
||||||
Preview: ${{ steps.netlify.outputs.deploy-url }}
|
Preview: ${{ steps.netlify.outputs.deploy-url }}
|
||||||
⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts.
|
⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue