Skip to content

Commit

Permalink
Merge pull request #61 from AhmedBasem20/refactor-pipelines
Browse files Browse the repository at this point in the history
Refactor the docs workflow
  • Loading branch information
etpeterson authored Apr 8, 2024
2 parents 5fe5728 + d22612c commit 2dc8e9a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 24 deletions.
39 changes: 39 additions & 0 deletions .github/actions/download-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Download Artifact
description: Download artifact from the same or different workflow

inputs:
name:
description: Artifact to be downloaded
required: true
type: string

runs:
using: composite
steps:
- name: Download Artifact
uses: actions/github-script@v6
with:
script: |
var inputs = ${{ toJSON(inputs) }}
var artifactName = inputs['name']
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == artifactName
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifactName}.zip`, Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip ${{ inputs.name }}.zip
shell: bash
34 changes: 10 additions & 24 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ permissions:
id-token: write
jobs:
build:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -39,28 +36,9 @@ jobs:
# Action to download artifacts from a different workflow (analysis.yml)
- name: 'Download artifact'
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: actions/github-script@v6
uses: ./.github/actions/download-artifact
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "Figures"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/Figures.zip`, Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip Figures.zip
name: 'Figures'

- name: Build html
run: |
Expand All @@ -75,6 +53,14 @@ jobs:
with:
path: 'docs/_build/html'

deploy:
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

0 comments on commit 2dc8e9a

Please sign in to comment.