From 0a17da198478ec545e7f186d2b60a4743268a8f4 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Tue, 14 Jul 2020 12:09:16 +0100 Subject: [PATCH] feat: add to IPFS on PR (#976) * feat: add to IPFS on PR - Adds work flow to add the rendered website to IPFS, whenever a commit is pushed. Adds a github status on the commit with a link to the rendered site. - Replaces hardcoded paths with the $GITHUB_WORKSPACE var. This makes the build work on forked repos, where the repo has to be renamed, and shields us from future issues if actions change their workspace dir. - Updated IPFS github action to pin to work with the new style github actions https://github.com/ipfs-shipyard/ipfs-github-action License: MIT Signed-off-by: Oli Evans --- .github/workflows/add-to-ipfs.yml | 49 +++++++++++++++++++ .../{main.yml => deploy-to-gh-pages.yml} | 4 +- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/add-to-ipfs.yml rename .github/workflows/{main.yml => deploy-to-gh-pages.yml} (94%) diff --git a/.github/workflows/add-to-ipfs.yml b/.github/workflows/add-to-ipfs.yml new file mode 100644 index 000000000..1cdcd2d6f --- /dev/null +++ b/.github/workflows/add-to-ipfs.yml @@ -0,0 +1,49 @@ +name: Add to IPFS + +on: [push] + +jobs: + add-to-ipfs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Install Go + run: | + sudo apt-get remove golang-go + sudo apt-get remove --auto-remove golang-go + sudo rm -rf /usr/local/go + sudo rm -rf /usr/local/go1.12 + sudo rm -rf /usr/local/go1.27 + sudo apt-get update + wget https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz + sudo tar -xvf go1.14.4.linux-amd64.tar.gz + sudo chown -R root:root ./go + sudo cp -r go /usr/local + sudo cp -r go /usr/local/go1.12 + sudo cp -r go /usr/local/go1.27 + sudo ln -sf /usr/local/go/bin/go /usr/bin/go + sudo echo 'GOROOT=/usr/local/go' >> ~/.profile + sudo echo 'GOPATH=$HOME/work' >>~/.profile + sudo echo 'PATH=$GOROOT/bin:$GOPATH/bin' >>~/.profile + source ~/.profile + + - name: Install deps-ga + run: | + sudo make deps-ga + + - name: Build + run: | + sudo chown -R root:root $GITHUB_WORKSPACE + sudo make build + + - uses: ipfs-shipyard/ipfs-github-action@v1.0.0 + with: + path_to_add: $GITHUB_WORKSPACE/build/website + cluster_host: /dnsaddr/cluster.ipfs.io + cluster_user: ${{ secrets.CLUSTER_USER }} + cluster_password: ${{ secrets.CLUSTER_PASSWORD }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/deploy-to-gh-pages.yml similarity index 94% rename from .github/workflows/main.yml rename to .github/workflows/deploy-to-gh-pages.yml index 88a2d336a..ed499824d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/deploy-to-gh-pages.yml @@ -50,7 +50,7 @@ jobs: - name: Build run: | - sudo chown -R root:root /home/runner/work/specs + sudo chown -R root:root $GITHUB_WORKSPACE sudo make build - name: Deploy using SSH @@ -58,7 +58,7 @@ jobs: DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - sudo chown -R runner /home/runner/work/specs/specs + sudo chown -R runner $GITHUB_WORKSPACE sudo chown -R runner .git/ eval "$(ssh-agent -s)" ssh-add - <<< "${DEPLOY_KEY}"