Publish Example App Tutorials #19
This file contains hidden or 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: Publish Example App Tutorials | |
on: | |
# Run when changes are pushed to example tutorials or metadata | |
push: | |
branches: | |
- main | |
paths: | |
- 'examples/*/*/tutorial.md' | |
- 'examples/*/*/metadata.json' | |
- 'examples/*/*/features.json' | |
# Allow manual triggering | |
workflow_dispatch: | |
concurrency: | |
group: example-tutorials | |
cancel-in-progress: false | |
jobs: | |
PublishExampleTutorials: | |
name: Process and Publish Example Tutorials | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout SDK Repo | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
with: | |
fetch-depth: 0 | |
- name: Checkout Docs Repo | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
with: | |
repository: immutable/docs | |
token: ${{ secrets.TS_IMMUTABLE_SDK_GITHUB_TOKEN }} | |
path: imx-docs | |
ref: DVR-295-docs-restructure | |
- name: Setup environment variables | |
run: | | |
echo "CLONE_DIR=./imx-docs" >> $GITHUB_ENV | |
- name: Setup Github | |
run: | | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
- name: setup | |
uses: ./.github/actions/setup | |
- name: Install Dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Process Example App Tutorials | |
run: | | |
# Generate example app JSON files | |
pnpm parse:examples | |
# Process tutorials and copy to docs repo | |
./.github/scripts/process-tutorials.sh | |
shell: bash | |
- name: Create Pull Request in Docs Repo | |
id: create_pr | |
run: | | |
cd "$CLONE_DIR" | |
if ! git status --porcelain | grep -q .; then | |
echo "No changes to commit" | |
echo "pr_url=" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
BRANCH_NAME="chore/ts-sdk-docs-update-${{ github.run_id }}" | |
git checkout -b $BRANCH_NAME | |
git add . | |
git commit -m "chore: example app usage guide updated" | |
git push -u origin $BRANCH_NAME | |
echo "Successfully pushed changes to docs repo on branch $BRANCH_NAME" | |
PR_URL=$(gh pr create \ | |
--title "auto(ts-immutable-sdk): example app usage guide updated" \ | |
--body "Automated PR from ts-immutable-sdk to update tutorials. This is safe for anyone to approve and merge." | |
--base DVR-295-docs-restructure \ | |
--repo immutable/docs) | |
echo "Successfully created PR in docs repo: $PR_URL" | |
echo "pr_url=${PR_URL}" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.TS_IMMUTABLE_SDK_GITHUB_TOKEN }} | |
shell: bash | |
- name: Notify Slack | |
if: steps.create_pr.outputs.pr_url != '' | |
uses: ./.github/actions/notify-slack-publish-status | |
with: | |
message: 'New automated TS SDK sample app tutorials PR is ready for review: ${{ steps.create_pr.outputs.pr_url }}' | |
webhook-url: ${{ secrets.SDK_DOCS_TUTORIALS_SLACK_WEBHOOK }} |