Skip to content

Commit

Permalink
async action
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcodercrane committed Aug 3, 2022
1 parent ce72f2f commit a001291
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 10 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/build-test-lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Workflow for Ubiquidity
name: Build and Test Workflow for Ubiquidity

on:
push:
Expand All @@ -20,9 +20,6 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-latest
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
API_KEY_ALCHEMY: ${{ secrets.API_KEY_ALCHEMY }}
permissions:
contents: read

Expand Down Expand Up @@ -56,7 +53,12 @@ jobs:
- name: Yarn test
run: yarn test:all

- name: Deploy Development
- name: Zip build directory
run: |
netlify link --id ${{ secrets.NETLIFY_SITE_ID_DEVELOPMENT }}
netlify deploy --prod --build --context development
mkdir -p ./pr
zip -r pull-request.zip ./web/dapp && cp pull-request.zip ./pr
- uses: actions/upload-artifact@v2
with:
name: pr
path: pr/
44 changes: 44 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Received PR and Deploy for Ubiquidity

on:
workflow_run:
workflows: ["Build and Test Workflow for Ubiquidity"]
types:
- completed

jobs:
receive-pr-and-deploy:
runs-on: ubuntu-latest
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
steps:
- name: "Download artifact"
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"
})[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.zip', Buffer.from(download.data));
- name: Extract files
run: unzip pr.zip && unzip pull-request.zip && ls

- name: Deploy Development
run: |
netlify link --id ${{ secrets.NETLIFY_SITE_ID_DEVELOPMENT }}
netlify deploy --prod
10 changes: 7 additions & 3 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
package = "@netlify/plugin-nextjs"

[build]
publish = "web/dapp"
command = "yarn build:fleek"

publish = "./"

[context.development.environment]
NETLIFY_NEXT_PLUGIN_SKIP = "true"

[context.staging.environment]
NETLIFY_NEXT_PLUGIN_SKIP = "true"

[context.production.environment]
NETLIFY_NEXT_PLUGIN_SKIP = "true"

0 comments on commit a001291

Please sign in to comment.