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) => {
|
|
|
|
return artifact.name == "public"
|
|
|
|
})[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');
|
|
|
|
fs.writeFileSync('${{github.workspace}}/public.zip', Buffer.from(download.data));
|
2022-07-17 19:25:44 -04:00
|
|
|
|
2022-07-19 07:47:08 -04:00
|
|
|
- name: Unzip artifact
|
|
|
|
run: unzip public.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-19 07:47:08 -04:00
|
|
|
projectId: privsec-356523
|