|
| 1 | +name: Triggerable workflow using website artifact from separate workflow |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + artifact_url: |
| 7 | + description: "Website publish folder files" |
| 8 | + required: true |
| 9 | + |
| 10 | + repository_dispatch: |
| 11 | + types: [artifact_ready] |
| 12 | + |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | +env: |
| 17 | + |
| 18 | + PACKAGES_TOKEN: ${{ secrets.NUGETKEY }} |
| 19 | + GITHUB_USERNAME: "Phil-NHS" |
| 20 | + |
| 21 | +jobs: |
| 22 | + |
| 23 | + set-gh-page-to-triggering-workflows-artifact: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + steps: |
| 27 | + |
| 28 | + - name: Print artifact URL (Manual Trigger) |
| 29 | + if: github.event_name == 'workflow_dispatch' |
| 30 | + run: echo "Artifact URL ${{ github.event.inputs.artifact_url }}" |
| 31 | + |
| 32 | + - name: Print artifact URL (Repository Dispatch) |
| 33 | + if: github.event_name == 'repository_dispatch' |
| 34 | + run: echo "Artifact URL ${{ github.event.client_payload.artifact_url }}" |
| 35 | + |
| 36 | + - name: Checkout repository |
| 37 | + uses: actions/checkout@v3 |
| 38 | + |
| 39 | + - name: Create docs directory |
| 40 | + run: mkdir -p docs |
| 41 | + |
| 42 | + |
| 43 | + - name: Download artifact |
| 44 | + env: |
| 45 | + ARTIFACT_URL: ${{ github.event.client_payload.artifact_url || github.event.inputs.artifact_url }} |
| 46 | + run: | |
| 47 | + echo "Downloading artifact from $ARTIFACT_URL" |
| 48 | + # Download the artifact using curl and extract it |
| 49 | + curl -L \ |
| 50 | + -H "Accept: application/vnd.github+json" \ |
| 51 | + -H "Authorization: Bearer $PACKAGES_TOKEN" \ |
| 52 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 53 | + "${ARTIFACT_URL}/zip" -o artifact.zip |
| 54 | +
|
| 55 | +
|
| 56 | + - name: unzip and move artifact |
| 57 | + run: | |
| 58 | + unzip artifact.zip -d docs/ |
| 59 | +
|
| 60 | + - name: Deploy to GitHub Pages |
| 61 | + uses: JamesIves/github-pages-deploy-action@v4 |
| 62 | + with: |
| 63 | + folder: docs |
| 64 | + branch: gh-pages |
0 commit comments