This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Triggerable workflow using website artifact from separate workflow | |
on: | |
workflow_dispatch: | |
inputs: | |
artifact_url: | |
description: "Website publish folder files" | |
required: true | |
repository_dispatch: | |
types: [artifact_ready] | |
permissions: | |
contents: write | |
env: | |
PACKAGES_TOKEN: ${{ secrets.NUGETKEY }} | |
GITHUB_USERNAME: "Phil-NHS" | |
jobs: | |
set-gh-page-to-triggering-workflows-artifact: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print artifact URL (Manual Trigger) | |
if: github.event_name == 'workflow_dispatch' | |
run: echo "Artifact URL ${{ github.event.inputs.artifact_url }}" | |
- name: Print artifact URL (Repository Dispatch) | |
if: github.event_name == 'repository_dispatch' | |
run: echo "Artifact URL ${{ github.event.client_payload.artifact_url }}" | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Create docs directory | |
run: mkdir -p docs | |
- name: Download artifact | |
env: | |
ARTIFACT_URL: ${{ github.event.client_payload.artifact_url || github.event.inputs.artifact_url }} | |
run: | | |
echo "Downloading artifact from $ARTIFACT_URL" | |
# Download the artifact using curl and extract it | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer $PACKAGES_TOKEN" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"${ARTIFACT_URL}/zip" -o artifact.zip | |
- name: unzip and move artifact | |
run: | | |
unzip artifact.zip -d docs/ | |
- name: Deploy to GitHub Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: docs | |
branch: gh-pages |