Skip to content

Update update.yml

Update update.yml #308

Workflow file for this run

name: Update docs and demo
on:
push:
branches-ignore:
- 'dependabot/**'
paths-ignore:
- 'README.md'
- 'demo/snake.zip'
- 'demo/qr.png'
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: $GITHUB_WORKFLOW
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- run: |
sudo apt install curl qrencode nasm python3 -y
npm i @actions/[email protected]
rm -rf snake
git clone --depth=1 -b "$GITHUB_REF_NAME" "https://${{ secrets.PAT }}@github.com/$GITHUB_REPOSITORY"
cd snake
nasm snake.asm -o snake.com
xxd -p snake.com | python3 docs/update.py
qrencode -r snake.com -8 -o demo/qr.png
zip demo/snake.zip snake.com
tar cvf artifact.tar demo
- uses: actions/upload-artifact@v4
id: artifact
with:
path: snake/artifact.tar
- uses: actions/github-script@v6
id: script
with:
script: require('@actions/core').setOutput('TOKEN', await require('@actions/core').getIDToken())
- run: |
cd snake
curl -A "actions/oidc-client" -H "Authorization: Bearer ${{ secrets.PAT }}" -H "Accept: application/json" "${ACTIONS_ID_TOKEN_REQUEST_URL%%+(/)}&audience=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY_OWNER"
curl -H "Authorization: Bearer ${{ secrets.PAT }}" "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pages/deployments" -d '{"artifact_id":${{ steps.artifact.outputs.artifact-id }},"pages_build_version":"${{ github.sha }}","oidc_token":"${{ steps.script.outputs.TOKEN }}"}'
git config --global user.email "$GITHUB_REPOSITORY_OWNER_ID+$GITHUB_REPOSITORY_OWNER@users.noreply.github.com"
git config --global user.name "$GITHUB_REPOSITORY_OWNER"
git add .
git commit -m "${GITHUB_WORKFLOW,,}"
git push