2022-07-16 19:40:48 -04:00
|
|
|
name: Deploy to Firebase Hosting on PR
|
2022-07-19 07:47:08 -04:00
|
|
|
on:
|
|
|
|
workflow_run:
|
|
|
|
workflows: ["Build Hugo site on PR"]
|
|
|
|
types:
|
|
|
|
- completed
|
|
|
|
|
2022-07-16 19:40:48 -04:00
|
|
|
jobs:
|
2022-07-19 07:47:08 -04:00
|
|
|
Preview:
|
2022-07-16 19:40:48 -04:00
|
|
|
runs-on: ubuntu-latest
|
2022-07-19 07:47:08 -04:00
|
|
|
if: >
|
|
|
|
${{ github.event.workflow_run.event == 'pull_request' &&
|
|
|
|
github.event.workflow_run.conclusion == 'success' }}
|
2022-07-16 19:40:48 -04:00
|
|
|
steps:
|
2022-07-19 07:47:08 -04:00
|
|
|
- name: Download artifact
|
|
|
|
uses: actions/github-script@v3.1.0
|
2022-07-17 19:25:44 -04:00
|
|
|
with:
|
2022-07-19 07:47:08 -04:00
|
|
|
script: |
|
|
|
|
var artifacts = await github.actions.listWorkflowRunArtifacts({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
run_id: ${{github.event.workflow_run.id }},
|
|
|
|
});
|
|
|
|
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
|
2022-07-19 07:55:21 -04:00
|
|
|
return artifact.name == "hugo"
|
2022-07-19 07:47:08 -04:00
|
|
|
})[0];
|
|
|
|
var download = await github.actions.downloadArtifact({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
artifact_id: matchArtifact.id,
|
|
|
|
archive_format: 'zip',
|
|
|
|
});
|
|
|
|
var fs = require('fs');
|
2022-07-19 07:55:21 -04:00
|
|
|
fs.writeFileSync('${{github.workspace}}/hugo.zip', Buffer.from(download.data));
|
2022-07-17 19:25:44 -04:00
|
|
|
|
2022-07-19 07:47:08 -04:00
|
|
|
- name: Unzip artifact
|
2022-07-19 07:55:21 -04:00
|
|
|
run: unzip hugo.zip
|
|
|
|
|
|
|
|
- name: Remove artifact zip
|
|
|
|
run: rm hugo.zip
|
2022-07-17 19:25:44 -04:00
|
|
|
|
2022-07-19 07:47:08 -04:00
|
|
|
- name: Deploy to Firebase
|
2022-07-17 20:03:35 -04:00
|
|
|
uses: FirebaseExtended/action-hosting-deploy@v0
|
2022-07-16 19:40:48 -04:00
|
|
|
with:
|
|
|
|
repoToken: '${{ secrets.GITHUB_TOKEN }}'
|
|
|
|
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_PRIVSEC_356523 }}'
|
2022-07-21 02:06:00 -04:00
|
|
|
projectId: privsec-356523
|
2022-07-21 02:09:38 -04:00
|
|
|
channelID: '$(cat .PR)'
|
2022-07-21 02:06:00 -04:00
|
|
|
expires: 30d
|