Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
atteggiani committed Nov 1, 2023
1 parent d399c73 commit e8c323c
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 25 deletions.
27 changes: 2 additions & 25 deletions .github/workflows/build_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,8 @@ jobs:
uses: actions/[email protected]
with:
script: |
console.log('run-id=',${{ github.event.workflow_run.id }});
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 == "pr_site"
})[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}}/pr_site.zip', Buffer.from(download.data));
- run: unzip pr_site.zip

- name: Deploy preview
uses: access-nri/[email protected]
with:
source-dir: site
action: deploy
pr-number: ${{ github.event.number }}
console.log('run_id=',${{ github.event.workflow_run.id }});
debug: true

close-preview:
if: ${{ github.event.action == 'closed' }}
Expand Down
101 changes: 101 additions & 0 deletions .github/workflows/build_preview_orig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Build PR preview

on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed

concurrency:
group: preview-${{ github.ref }}
cancel-in-progress: true

jobs:
build-preview:
if: ${{ github.event.action != 'closed' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install dependencies
run: pip install -r requirements.txt

- name: Build
# builds to "site" directory by default
run: |
mkdocs build -f mkdocs.yml -d site
- name: Save built site
run: |
mkdir -p ./pr_site
mv site ./pr_site/.
- uses: actions/upload-artifact@v3
with:
name: pr_site
path: pr_site/

deploy-preview:
needs: build-preview
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: 3.x

- name: "Download built site"
uses: actions/[email protected]
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 == "pr_site"
})[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}}/pr_site.zip', Buffer.from(download.data));
- run: unzip pr_site.zip

- name: Deploy preview
uses: access-nri/[email protected]
with:
source-dir: site
action: deploy
pr-number: ${{ github.event.number }}

close-preview:
if: ${{ github.event.action == 'closed' }}
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Clean preview
uses: access-nri/[email protected]
with:
action: remove
pr-number: ${{ github.event.number }}

0 comments on commit e8c323c

Please sign in to comment.