From 6be74976d6705ff31aac91161f3b3e0295ed1fc8 Mon Sep 17 00:00:00 2001 From: galargh Date: Tue, 30 Jul 2024 19:23:47 +0100 Subject: [PATCH] ci: migrate from CircleCI to GitHub Actions --- .circleci/config.yml | 51 ------------------- .github/workflows/build-deploy.yml | 81 ++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 51 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/build-deploy.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 69f324d..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,51 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: circleci/node:10.15.1-browsers - environment: - NO_SANDBOX: true - steps: - - checkout - - run: - command: npm ci - - run: - command: npm run build - - persist_to_workspace: - root: . - paths: - - build - - deploy: - docker: - - image: olizilla/ipfs-dns-deploy:latest - environment: - DOMAIN: peerpad.net - SUBDOMAIN: experiments - BUILD_DIR: build - steps: - - attach_workspace: - at: /tmp/workspace - - run: - name: Deploy website to IPFS - command: | - pin_name="$SUBDOMAIN.$DOMAIN build $CIRCLE_BUILD_NUMBER" - - hash=$(pin-to-cluster.sh "$pin_name" /tmp/workspace/$BUILD_DIR) - - echo "Website added to IPFS: https://ipfs.io/ipfs/$hash" - - if [ "$CIRCLE_BRANCH" == "master" ] ; then - dnslink-dnsimple -d $DOMAIN -r _dnslink.$SUBDOMAIN -l /ipfs/$hash - - fi - -workflows: - version: 2 - build-deploy: - jobs: - - build - - deploy: - context: ipfs-dns-deploy - requires: - - build diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml new file mode 100644 index 0000000..d194de1 --- /dev/null +++ b/.github/workflows/build-deploy.yml @@ -0,0 +1,81 @@ +name: Build and Deploy to IPFS + +on: + pull_request: + push: + branches: + - master + - github-actions + +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '10.*' + - run: npm ci + - run: npm run build + - uses: actions/upload-artifact@v4 + with: + name: build + path: build + deploy: + if: github.event_name == 'push' + needs: [build] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: ipfs-shipyard/ipfs-dns-deploy + - name: Download build + uses: actions/download-artifact@v4 + with: + name: build + path: build + - run: ls -la dist + - env: + CIRCLE_PROJECT_USERNAME: ipfs-shipyard + CIRCLE_PROJECT_REPONAME: ipfs-block-party + CIRCLE_SHA1: ${{ github.sha }} + CLUSTER_USER: ${{ secrets.CLUSTER_USER }} + CLUSTER_PASSWORD: ${{ secrets.CLUSTER_PASSWORD }} + GITHUB_TOKEN: ${{ github.token }} + BUILD_DIR: build + SCRIPT: | + set -e + set -o pipefail + set -x + + apk add --no-cache jq curl + + pin_name="$CIRCLE_PROJECT_REPONAME $BUILD_DIR $GITHUB_RUN_ID" + + hash=$(pin-to-cluster.sh "$pin_name" $BUILD_DIR) + + echo "Website added to IPFS: https://dweb.link/ipfs/$hash" + + # Update DNSlink + if [ "$GITHUB_REF_NAME" == "master" ] ; then + dnslink-dnsimple -d peerpad.net -r _dnslink.experiments -l /ipfs/$hash + fi + run: | + docker build -t ipfs-dns-deploy . + docker run --rm -v $PWD:/tmp \ + -w /tmp \ + -e GITHUB_TOKEN \ + -e GITHUB_RUN_ID \ + -e GITHUB_REF_NAME \ + -e CIRCLE_PROJECT_USERNAME \ + -e CIRCLE_PROJECT_REPONAME \ + -e CIRCLE_SHA1 \ + -e CLUSTER_USER \ + -e CLUSTER_PASSWORD \ + -e BUILD_DIR \ + ipfs-dns-deploy \ + bash -c "$SCRIPT"