From a666998d8d237b69780f82e619b6a4c7c7883a6b Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Thu, 4 Jan 2024 18:17:08 +0100 Subject: [PATCH] build docker image and update gh pages only on final releases, add ipfs deployment script --- .github/workflows/build.yml | 44 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12299f5..62ec9c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ permissions: jobs: # deploy docker to github registry deployDocker: - if: github.event_name == 'release' + if: github.event_name == 'release' && !github.event.release.prerelease runs-on: ubuntu-latest env: REGISTRY: ghcr.io @@ -50,8 +50,7 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # deploy static - deployStatic: + deployPackage: runs-on: ubuntu-latest steps: - name: Checkout @@ -125,9 +124,7 @@ jobs: --data-binary @"$filename" \ "$url" - # deploy gh pages - deployPages: - if: github.event_name == 'release' + deployWWW: concurrency: ci-${{ github.ref }} environment: name: github-pages @@ -138,6 +135,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Pages + if: github.event_name == 'release' && !github.event.release.prerelease uses: actions/configure-pages@v4 - name: Build @@ -145,10 +143,44 @@ jobs: bash build.sh - name: Upload artifact + if: github.event_name == 'release' && !github.event.release.prerelease uses: actions/upload-pages-artifact@v3 with: path: "./dist/" - name: Deploy to GitHub Pages id: deployment + if: github.event_name == 'release' && !github.event.release.prerelease uses: actions/deploy-pages@v4 + + - name: Prepare Node 18 + uses: actions/setup-node@v2 + with: + node-version: 18 + + - name: Upload to ipfs + run: | + npm install -g @web3-storage/w3cli + echo "${{secrets.W3_ACCESS}}" > ~/.config/w3access/w3cli.json + w3 space use anser + w3 up ./dist/ --json > ipfs.json + cid=$(jq -r '.root["/"]' ipfs.json) + echo "$cid" > deploy.log + + - name: Write ipfs link to release description + if: false + run: | + set -e + echo "${GITHUB_EVENT_PATH}" + cat ${GITHUB_EVENT_PATH} + releaseId=$(jq --raw-output '.release.id' ${GITHUB_EVENT_PATH}) + + deployLink=`cat deploy.log` + echo $deployLink + + # Add to release description + curl -X PATCH \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/$releaseId \ + -d "{\"body\": \"${deployLink}\"}"