Publish #22
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 | |
| description: | | |
| This workflow publishes devcontainer features and generates documentation. | |
| It creates a pull request for the documentation if changes are detected. | |
| on: | |
| workflow_dispatch: | |
| workflow_run: | |
| workflows: ["Tests", "Upgrade Lockfiles"] | |
| branches: ["main"] | |
| types: | |
| - completed | |
| jobs: | |
| publish: | |
| name: Publish Features | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: "Publish Features" | |
| uses: devcontainers/action@1082abd5d2bf3a11abccba70eef98df068277772 # v1.4.3 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| publish-features: "true" | |
| base-path-to-features: "./src" | |
| generate-docs: "true" | |
| - name: Create PR for Documentation | |
| id: push_image_info | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -e | |
| cleanup() { | |
| echo "🧹 Cleaning up..." | |
| git checkout - | |
| echo "✔️ OK. Cleaned up." | |
| } | |
| trap cleanup EXIT | |
| echo "🚀 Creating PR for documentation..." | |
| git config --global user.email ${{vars.GH_ACTIONS_USERNAME}}@users.noreply.github.com | |
| git config --global user.name ${{vars.GH_ACTIONS_USERNAME}} | |
| git config pull.rebase false | |
| branch=automated-documentation-update-$GITHUB_RUN_ID | |
| git checkout -b $branch | |
| git add */**/README.md | |
| git commit \ | |
| -m "docs(src/all): Automated documentation update [skip ci]" \ | |
| -m ":robot: This PR was created by a GitHub Action" \ | |
| -m "Co-authored-by: Bart Venter <bartventer@outlook.com>" || export NO_UPDATES=true | |
| [[ $NO_UPDATES == "true" ]] && echo "No updates to commit." && exit 0 | |
| git push origin "$branch" | |
| pr_url=$(gh pr create \ | |
| --fill \ | |
| --label "documentation" | |
| ) | |
| gh pr merge "${pr_url}" --admin --rebase --delete-branch |