Skip to content

Commit

Permalink
chore: now docs are autogenerated as part of the release process
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytonline committed Sep 6, 2024
1 parent 9ce759a commit 8f1bb51
Showing 1 changed file with 68 additions and 1 deletion.
69 changes: 68 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,57 @@ jobs:
name: Test, lint, & build
uses: ./.github/workflows/test.yaml

prerelease:
name: Update documentation
runs-on: ubuntu-latest
outputs:
pr_number: ${{ steps.create_pr.outputs.pr_number }}
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.OS_GITHUB_APP_ID }}
private_key: ${{ secrets.OS_GITHUB_APP_PRIVATE_KEY }}

- name: "☁️ checkout repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}

- name: "🤲 Setup Just"
uses: extractions/setup-just@v2

- name: "📗 generate documentation"
run: just gen-docs

- name: Create PR for documentation update
id: create_pr
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
timestamp=$(date +"%Y%m%d%H%M%S")
branch_name="chore-automated-doc-updates-$timestamp"
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git checkout -b "$branch_name"
git add .
if git diff --staged --quiet; then
echo "No changes to commit"
echo "pr_number=" >> $GITHUB_OUTPUT
else
git commit -m "chore: update documentation ($timestamp)"
git push -u origin "$branch_name"
pr_number=$(gh pr create --title "chore: update documentation ($timestamp)" --body "Automated documentation update for release" --base ${{ github.ref_name }} --head "$branch_name")
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
gh pr merge $pr_number --auto --delete-branch --squash
fi
release:
needs: [test, prerelease]
outputs:
release-tag: ${{ steps.semantic-release.outputs.release-tag }}
release-tag: ${{ steps.semantic-release.outputs.release-tag }}
name: Semantic release
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down Expand Up @@ -46,6 +94,25 @@ jobs:
- name: "🔧 install npm@latest"
run: npm i -g npm@latest

- name: "Wait for PR to be merged"
if: needs.prerelease.outputs.pr_number != ''
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
pr_number="${{ needs.prerelease.outputs.pr_number }}"
while true; do
pr_state=$(gh pr view $pr_number --json state -q .state)
if [ "$pr_state" = "MERGED" ]; then
echo "PR has been merged"
break
elif [ "$pr_state" = "CLOSED" ]; then
echo "PR was closed without merging"
exit 1
fi
echo "Waiting for PR to be merged..."
sleep 10
done
- name: "🚀 release"
id: semantic-release
uses: open-sauced/release@v2
Expand Down

0 comments on commit 8f1bb51

Please sign in to comment.