Skip to content

[CI] - Fixing #205 - More status logs in CI #126

[CI] - Fixing #205 - More status logs in CI

[CI] - Fixing #205 - More status logs in CI #126

Workflow file for this run

name: Build and deploy documentation website
on:
push:
branches:
main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/static_shock_docs
steps:
# Checkout the repository
- uses: actions/checkout@v3
# Setup a Dart environment
- uses: dart-lang/setup-dart@v1
# Download all the packages that the app uses
- run: dart pub get
# Build the static site
- run: dart run bin/static_shock_docs.dart ci
env:
GHUB_DOC_WEBSITE_TOKEN: ${{ vars.GHUB_DOC_WEBSITE_TOKEN }}
STATIC_SHOCK_ALGOLIA_APP_ID: ${{ vars.STATIC_SHOCK_ALGOLIA_APP_ID }}
STATIC_SHOCK_ALGOLIA_API_KEY: ${{ vars.STATIC_SHOCK_ALGOLIA_API_KEY }}
# Zip and upload the static site.
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./packages/static_shock_docs/build
- name: Check for cache changes
id: detect_changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Check for changes in source/.shock
if [[ -n "$(git status --porcelain source/.shock/cache)" ]]; then
echo "Changes detected in the source cache"
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "No changes in the source cache"
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Commit and push cache changes to new PR branch
run: |
BRANCH_NAME="cache-updates-${{ github.run_id }}"
git switch -c $BRANCH_NAME
echo "Running git status"
git status
echo ""
echo "Running git diff --stat"
git diff --stat
echo ""
echo "Adding cache files for commit"
git add source
echo ""
echo "Running git status after staging files"
git status
echo ""
echo "Committing changes to branch"
git commit -m "[GitHub Deployment] - Push changes to the source cache (run ID: ${{ github.run_id }})"
echo ""
echo "Verifying latest commit on new branch"
git log -1
echo ""
echo "Pushing branch to origin"
git push origin $BRANCH_NAME
echo ""
- name: Create cache update pull request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: main
branch: cache-updates-${{ github.run_id }}
title: "[GitHub] - Update source cache for latest deployment"
body: "Auto-generated update to the source cache after the latest public deployment."
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4