1
0
mirror of https://github.com/PrivSec-dev/privsec.dev synced 2024-11-17 20:11:33 -05:00
privsec.dev/.github/workflows/firebase-hosting-pull-request.yml
Tommy 422c26c6ce
Safer Workflow
Signed-off-by: Tommy <contact@tommytran.io>
2022-08-25 18:40:07 -04:00

44 lines
1.5 KiB
YAML

name: Deploy to Firebase Hosting on PR
on:
workflow_run:
workflows: ["Build Hugo site on PR"]
types:
- completed
jobs:
Preview:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download artifact
uses: actions/github-script@v3.1.0
with:
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));
- name: Unzip artifact
run: unzip public.zip
- name: Deploy to Firebase
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_PRIVSEC_356523 }}'
projectId: privsec-356523