|
| 1 | +name: Update Self-Hosted Changelog |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 * * * *" |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + update-self-hosted-changelog: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v5 |
| 13 | + with: |
| 14 | + ref: main |
| 15 | + - name: Sync self-hosted releases from fern-platform |
| 16 | + env: |
| 17 | + GH_TOKEN: ${{ secrets.FERN_GITHUB_TOKEN }} |
| 18 | + run: | |
| 19 | + set -euo pipefail |
| 20 | + DIR="fern/products/docs/pages/self-hosted/changelog" |
| 21 | + mkdir -p "$DIR" |
| 22 | +
|
| 23 | + gh api -H "Accept: application/vnd.github+json" \ |
| 24 | + "repos/fern-api/fern-platform/releases?per_page=50" \ |
| 25 | + --jq '.[] | select(.tag_name | startswith("docs@")) | "\(.tag_name)\t\(.published_at)"' \ |
| 26 | + | sort -k2 \ |
| 27 | + > /tmp/releases.tsv |
| 28 | +
|
| 29 | + while IFS=$'\t' read -r tag published; do |
| 30 | + version="${tag#docs@}" |
| 31 | + date="${published%%T*}" |
| 32 | + file="$DIR/$date.mdx" |
| 33 | + version_escaped="${version//./\\.}" |
| 34 | +
|
| 35 | + if grep -rqE "^### v${version_escaped}$" "$DIR" 2>/dev/null; then |
| 36 | + continue |
| 37 | + fi |
| 38 | +
|
| 39 | + if [ -s "$file" ]; then |
| 40 | + printf '\n### v%s\n\n```dockerfile\nFROM fernenterprise/fern-self-hosted:%s\n```\n' "$version" "$version" >> "$file" |
| 41 | + else |
| 42 | + printf '### v%s\n\n```dockerfile\nFROM fernenterprise/fern-self-hosted:%s\n```\n' "$version" "$version" > "$file" |
| 43 | + fi |
| 44 | + done < /tmp/releases.tsv |
| 45 | + - name: create PR |
| 46 | + id: cpr |
| 47 | + uses: peter-evans/create-pull-request@v8 |
| 48 | + with: |
| 49 | + commit-message: "update self-hosted changelog from fern-platform releases" |
| 50 | + title: "Update self-hosted changelog" |
| 51 | + branch: update-self-hosted-changelog |
| 52 | + base: main |
| 53 | + delete-branch: true |
| 54 | + - name: Enable Pull Request Automerge |
| 55 | + if: steps.cpr.outputs.pull-request-operation == 'created' |
| 56 | + uses: peter-evans/enable-pull-request-automerge@v3 |
| 57 | + with: |
| 58 | + pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} |
| 59 | + merge-method: squash |
| 60 | + - name: Approving PR |
| 61 | + if: steps.cpr.outputs.pull-request-operation == 'created' |
| 62 | + env: |
| 63 | + GH_TOKEN: ${{ secrets.FERN_GITHUB_TOKEN }} |
| 64 | + run: | |
| 65 | + echo "Approving PR" |
| 66 | + gh pr review ${{ steps.cpr.outputs.pull-request-number }} --approve |
0 commit comments