Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,39 @@ jobs:

strategy:
matrix:
node-version: ['22', '24']
node-version:
- { v: 22 }
- { v: 24, isLatest: yes }

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version.v }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
node-version: ${{ matrix.node-version.v }}
- run: npm clean-install
- run: npm audit signatures
- run: npm run all
- run: npm run test

- name: '[PR Preview] Upload dist folder'
if: ${{github.event_name == 'pull_request' && matrix.node-version.isLatest}}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: dist
path: |
dist

- name: '[PR Preview] Store PR metadata'
if: ${{github.event_name == 'pull_request' && matrix.node-version.isLatest}}
run: |
touch ./pr_metadata.ini
echo "pr=${{github.event.number}}" >> ./pr_metadata.ini
echo "ref=${{github.sha}}" >> ./pr_metadata.ini

- name: '[PR Preview] Upload PR metadata'
if: ${{github.event_name == 'pull_request' && matrix.node-version.isLatest}}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: pr_metadata
path: ./pr_metadata.ini
50 changes: 50 additions & 0 deletions .github/workflows/deploy-pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deploy PR Preview

on:
workflow_run:
workflows: [build]
types:
- completed

permissions:
contents: read
actions: write
deployments: write

jobs:
deploy-preview:
runs-on: ubuntu-latest
if: ${{github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'}}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '24'

- name: Download all artifacts (dist folder and pr_metadata)
uses: dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 # v11
with:
github_token: ${{secrets.GITHUB_TOKEN}}
run_id: ${{github.event.workflow_run.id}}
allow_forks: true

- name: Read pr_metadata
id: pr_metadata
run: cat pr_metadata/pr_metadata.ini >> $GITHUB_OUTPUT

- name: Deploy to Netlify
env:
NETLIFY_AUTH_TOKEN: ${{secrets.NETLIFY_AUTH_TOKEN}}
NETLIFY_SITE_ID: ${{secrets.NETLIFY_SITE_ID}}
run: npx netlify deploy --no-build --dir=. --alias=pr-${{steps.pr_metadata.outputs.pr}}

- name: Run afterDeploy script
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const { afterDeploy } = await import('${{github.workspace}}/scripts/pr_preview.js');
await afterDeploy({ core, github, context })(
'${{steps.pr_metadata.outputs.pr}}',
'${{steps.pr_metadata.outputs.ref}}',
);
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
#### :mortar_board: Walkthrough / Help
#### :hammer: Development
* Add signatures audit to CI build pipeline and pin github action's versions ([#11103], thanks [@Harvester57])
* Configure preview deployments for Pull Requests ([#11332], thanks [@k-yle])

[#7629]: https://github.com/openstreetmap/iD/pull/7629
[#8440]: https://github.com/openstreetmap/iD/pull/8440
Expand All @@ -88,6 +89,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
[#11211]: https://github.com/openstreetmap/iD/issues/11211
[#11247]: https://github.com/openstreetmap/iD/issues/11247
[#11319]: https://github.com/openstreetmap/iD/pull/11319
[#11332]: https://github.com/openstreetmap/iD/pull/11332
[#11333]: https://github.com/openstreetmap/iD/pull/11333
[#11335]: https://github.com/openstreetmap/iD/issues/11335
[@bhavyaKhatri2703]: https://github.com/bhavyaKhatri2703
Expand Down
Loading