|
| 1 | +name: Deploy release feed to Pages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["master"] |
| 6 | + |
| 7 | + # Allows you to run this workflow manually from the Actions tab |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + pages: write |
| 14 | + id-token: write |
| 15 | + |
| 16 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 17 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 18 | +concurrency: |
| 19 | + group: "pages" |
| 20 | + cancel-in-progress: false |
| 21 | + |
| 22 | +jobs: |
| 23 | + deploy: |
| 24 | + # For production (plaidev/karte-ios-sdk): |
| 25 | + if: github.repository == 'plaidev/karte-ios-sdk' |
| 26 | + environment: |
| 27 | + name: github-pages |
| 28 | + url: ${{ steps.deployment.outputs.page_url }} |
| 29 | + runs-on: macos-latest |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 |
| 33 | + |
| 34 | + - name: Check commit message |
| 35 | + id: check_message |
| 36 | + run: | |
| 37 | + MESSAGE=$(git log -1 --pretty=%B) |
| 38 | + if echo "$MESSAGE" | grep -q "Merge release"; then |
| 39 | + echo "should_deploy=true" >> $GITHUB_OUTPUT |
| 40 | + echo "✅ Commit message contains 'Merge release' - proceeding with deployment" |
| 41 | + else |
| 42 | + echo "should_deploy=false" >> $GITHUB_OUTPUT |
| 43 | + echo "⏭️ Commit message does not contain 'Merge release' - skipping deployment" |
| 44 | + fi |
| 45 | +
|
| 46 | + - name: Generate Atom Feed |
| 47 | + if: steps.check_message.outputs.should_deploy == 'true' |
| 48 | + run: | |
| 49 | + mkdir -p docs |
| 50 | + LINK_URL="https://developers.karte.io/docs/release-notes-ios-sdk-v2#/" |
| 51 | + FEED_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/releases.atom" |
| 52 | +
|
| 53 | + ruby scripts/generate_feed.rb CHANGELOG.md "${FEED_URL}" "${LINK_URL}" > docs/releases.atom |
| 54 | +
|
| 55 | + echo "Generated Atom feed from CHANGELOG with link to: ${LINK_URL}" |
| 56 | + - name: Generate index.html |
| 57 | + if: steps.check_message.outputs.should_deploy == 'true' |
| 58 | + run: | |
| 59 | + FEED_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/releases.atom" |
| 60 | + sed "s|{{FEED_URL}}|${FEED_URL}|g" .github/PAGES_TEMPLATE/index.html.template > docs/index.html |
| 61 | + echo "Generated index.html with feed URL: ${FEED_URL}" |
| 62 | +
|
| 63 | + - name: Setup Pages |
| 64 | + if: steps.check_message.outputs.should_deploy == 'true' |
| 65 | + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 |
| 66 | + with: |
| 67 | + enablement: true |
| 68 | + |
| 69 | + - name: Upload artifact |
| 70 | + if: steps.check_message.outputs.should_deploy == 'true' |
| 71 | + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 |
| 72 | + with: |
| 73 | + # Upload docs directory containing releases.atom and index.html |
| 74 | + path: 'docs' |
| 75 | + |
| 76 | + - name: Deploy to GitHub Pages |
| 77 | + if: steps.check_message.outputs.should_deploy == 'true' |
| 78 | + id: deployment |
| 79 | + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 |
0 commit comments