From 6ccdf3586fda9f0b478927ce5b5fcd4337fd1f80 Mon Sep 17 00:00:00 2001 From: Victor Oliva Date: Fri, 17 May 2024 17:17:35 +0200 Subject: [PATCH] ci: deploy to gh-pages directly from main branch --- .github/workflows/deploy.yml | 51 --------------------------------- .github/workflows/publish.yml | 53 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index c1d07e5c..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: deploy - -on: - push: - branches: [main] - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: npm i - - name: Build - run: npm run build - - name: Setup git credentials - run: | - mkdir --parents ~/.ssh - DEPLOY_KEY_FILE=~/.ssh/deploy_key - echo "${{ secrets.SSH_DEPLOY_KEY }}" > "$DEPLOY_KEY_FILE" - chmod 600 "$DEPLOY_KEY_FILE" - - SSH_KNOWN_HOSTS_FILE="$HOME/.ssh/known_hosts" - ssh-keyscan -H "github.com" > "$SSH_KNOWN_HOSTS_FILE" - - - name: Clone deploy repo - run: | - DEPLOY_KEY_FILE=~/.ssh/deploy_key - SSH_KNOWN_HOSTS_FILE="$HOME/.ssh/known_hosts" - export GIT_SSH_COMMAND="ssh -i "$DEPLOY_KEY_FILE" -o UserKnownHostsFile=$SSH_KNOWN_HOSTS_FILE" - mkdir deploy - cd deploy - git clone git@github.com:polkadot-api/polkadot-api-docs.git ./ - git checkout --track origin/gh-pages - /bin/rm -rf * - cd .. - - name: Move new release - run: | - cp -R docs/dist/. deploy/ - - name: Commit and push - run: | - DEPLOY_KEY_FILE=~/.ssh/deploy_key - SSH_KNOWN_HOSTS_FILE="$HOME/.ssh/known_hosts" - export GIT_SSH_COMMAND="ssh -i "$DEPLOY_KEY_FILE" -o UserKnownHostsFile=$SSH_KNOWN_HOSTS_FILE" - cd deploy - git config --global user.email "deployment@github.com" - git config --global user.name "Github Deployment" - git add . - git commit -m "deploy latest main" - git push origin gh-pages diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..3f5871a8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,53 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy static content to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.5.3 + - uses: pnpm/action-setup@v2 + with: + version: 8 + - name: Setup Node.js 20 + uses: actions/setup-node@v3 + with: + node-version: 20 + cache: pnpm + - name: Install deps + run: pnpm install + - name: Build + run: pnpm build + - name: Setup Pages + uses: actions/configure-pages@v3 + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + # Upload dist repository + path: "./docs/dist" + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1