deploy to gh pages #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
export GIT_SSH_COMMAND="ssh -i "$DEPLOY_KEY_FILE" -o UserKnownHostsFile=$SSH_KNOWN_HOSTS_FILE" | |
export GIT_REPOSITORY="[email protected]:polkadot-api/polkadot-api-docs.git" | |
- name: Clone deploy repo | |
run: | | |
mkdir deploy | |
cd deploy | |
git clone "$GIT_REPOSITORY" ./ | |
git checkout --track origin/gh-pages | |
/bin/rm -rf * | |
cd .. | |
- name: Move new release | |
run: cp -R dist/* deploy/ | |
- name: Commit and push | |
run: | | |
cd deploy | |
git commit -m "deploy latest main" | |
git push origin gh-pages |