-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
name: Build and Publish Nominatim site | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
- 'staging' | ||
- 'nominatim-ui' | ||
|
||
jobs: | ||
nominatim: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
|
@@ -15,47 +19,33 @@ jobs: | |
|
||
- name: Set environment variables - Staging | ||
if: github.ref == 'refs/heads/staging' | ||
uses: allenevans/[email protected] | ||
with: | ||
NOMINATIM_API: https://nominatim-api.staging.openhistoricalmap.org/ | ||
NOMINATIM_BUCKET: nominatim-staging.openhistoricalmap.org | ||
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.STAGING_NOMINATIM_CLOUDFRONT_ID }} | ||
run: | | ||
echo "NOMINATIM_API=https://nominatim-api.staging.openhistoricalmap.org/" >> $GITHUB_ENV | ||
echo "NOMINATIM_BUCKET=nominatim-staging.openhistoricalmap.org" >> $GITHUB_ENV | ||
echo "CLOUDFRONT_DISTRIBUTION_ID=${{ secrets.STAGING_NOMINATIM_CLOUDFRONT_ID }}" >> $GITHUB_ENV | ||
- name: Set environment variables - Production | ||
if: github.ref == 'refs/heads/main' | ||
uses: allenevans/[email protected] | ||
with: | ||
NOMINATIM_API: 'https://nominatim-api.openhistoricalmap.org/' | ||
NOMINATIM_BUCKET: 'nominatim.openhistoricalmap.org' | ||
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.PRODUCTION_NOMINATIM_CLOUDFRONT_ID }} | ||
run: | | ||
echo "NOMINATIM_API=https://nominatim-api.openhistoricalmap.org/" >> $GITHUB_ENV | ||
echo "NOMINATIM_BUCKET=nominatim.openhistoricalmap.org" >> $GITHUB_ENV | ||
echo "CLOUDFRONT_DISTRIBUTION_ID=${{ secrets.PRODUCTION_NOMINATIM_CLOUDFRONT_ID }}" >> $GITHUB_ENV | ||
- name: Checkout nominatim-ui repo | ||
- name: Checkout nominatim-ui repo (Specific SHA) | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: OpenHistoricalMap/nominatim-ui | ||
ref: 81e184d68b5bbe09a18eca79e9a73c08971bcf74 | ||
ref: c14d033389acedf4dcbaabd9d88e14bc40212279 | ||
fetch-depth: 0 | ||
|
||
- name: Use Node.js 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'npm' | ||
|
||
- name: Cache node modules | ||
id: cache-node-modules | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Install modules | ||
if: steps.cache-node-modules.outputs.cache-hit != 'true' | ||
run: npm install | ||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build nominatim-ui frontend | ||
run: | | ||
|
@@ -67,16 +57,15 @@ jobs: | |
with: | ||
python-version: '3.8' | ||
|
||
- name: Install aws cli | ||
- name: Install AWS CLI | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install awscli | ||
- name: Push data to s3 and clean cloudfront cache | ||
if: ${{ success() }} | ||
- name: Deploy to S3 and Invalidate CloudFront | ||
run: | | ||
aws s3 sync dist/ s3://${NOMINATIM_BUCKET}/ | ||
aws cloudfront create-invalidation --distribution-id=${CLOUDFRONT_DISTRIBUTION_ID} --paths=/ | ||
aws s3 sync dist/ s3://${NOMINATIM_BUCKET}/ --delete | ||
aws cloudfront create-invalidation --distribution-id=${CLOUDFRONT_DISTRIBUTION_ID} --paths "/*" | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |