From 63029e717b91e1b9744c6c50a6edd83860e02532 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 15 Mar 2024 18:12:31 -0500 Subject: [PATCH 1/5] Update env vars staging configs --- .github/workflows/chartpress.yaml | 16 ++++++++-------- values.staging.template.yaml | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/chartpress.yaml b/.github/workflows/chartpress.yaml index deb70199..13c7fc87 100644 --- a/.github/workflows/chartpress.yaml +++ b/.github/workflows/chartpress.yaml @@ -50,14 +50,14 @@ jobs: STAGING_OAUTH_CLIENT_ID: ${{ secrets.STAGING_OAUTH_CLIENT_ID }} STAGING_OAUTH_KEY: ${{ secrets.STAGING_OAUTH_KEY }} STAGING_S3_BUCKET: ${{ secrets.STAGING_S3_BUCKET }} - STAGING_TILER_DB: ${{ secrets.STAGING_TILER_DB }} - STAGING_TILER_DB_EBS: ${{ secrets.STAGING_TILER_DB_EBS }} - STAGING_TILER_DB_HOST: ${{ secrets.STAGING_TILER_DB_HOST }} + # STAGING_TILER_DB: ${{ secrets.STAGING_TILER_DB }} + # STAGING_TILER_DB_EBS: ${{ secrets.STAGING_TILER_DB_EBS }} + # STAGING_TILER_DB_HOST: ${{ secrets.STAGING_TILER_DB_HOST }} STAGING_TILER_DB_PASSWORD: ${{ secrets.STAGING_TILER_DB_PASSWORD }} - STAGING_TILER_DB_USER: ${{ secrets.STAGING_TILER_DB_USER }} - STAGING_TILER_IMPOSM_EBS: ${{ secrets.STAGING_TILER_IMPOSM_EBS }} + # STAGING_TILER_DB_USER: ${{ secrets.STAGING_TILER_DB_USER }} + # STAGING_TILER_IMPOSM_EBS: ${{ secrets.STAGING_TILER_IMPOSM_EBS }} STAGING_TILER_IMPOSM_REPLICATION_URL: ${{ secrets.STAGING_TILER_IMPOSM_REPLICATION_URL }} - STAGING_TILER_SERVER_EBS: ${{ secrets.STAGING_TILER_SERVER_EBS }} + # STAGING_TILER_SERVER_EBS: ${{ secrets.STAGING_TILER_SERVER_EBS }} STAGING_TILER_CACHE_AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_TILER_CACHE_AWS_ACCESS_KEY_ID }} STAGING_TILER_CACHE_AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_TILER_CACHE_AWS_SECRET_ACCESS_KEY }} STAGING_TM_API_CONSUMER_KEY: ${{ secrets.STAGING_TM_API_CONSUMER_KEY }} @@ -67,12 +67,12 @@ jobs: STAGING_TM_API_DB_PASSWORD: ${{ secrets.STAGING_TM_API_DB_PASSWORD }} STAGING_TM_API_DB_USER: ${{ secrets.STAGING_TM_API_DB_USER }} STAGING_TM_API_SECRET: ${{ secrets.STAGING_TM_API_SECRET }} - STAGING_NOMINATIM_DB_EBS: ${{ secrets.STAGING_NOMINATIM_DB_EBS }} + # STAGING_NOMINATIM_DB_EBS: ${{ secrets.STAGING_NOMINATIM_DB_EBS }} # STAGING_NOMINATIM_PG_PORT: ${{ secrets.STAGING_NOMINATIM_PG_PORT }} # STAGING_NOMINATIM_PG_USER: ${{ secrets.STAGING_NOMINATIM_PG_USER }} STAGING_NOMINATIM_PG_PASSWORD: ${{ secrets.STAGING_NOMINATIM_PG_PASSWORD }} # STAGING_NOMINATIM_PG_DATABASE: ${{ secrets.STAGING_NOMINATIM_PG_DATABASE }} - STAGING_OVERPASS_API_DB_EBS: ${{ secrets.STAGING_OVERPASS_API_DB_EBS }} + # STAGING_OVERPASS_API_DB_EBS: ${{ secrets.STAGING_OVERPASS_API_DB_EBS }} STAGING_NEW_RELIC_LICENSE_KEY: ${{ secrets.STAGING_NEW_RELIC_LICENSE_KEY }} STAGING_NEW_RELIC_APP_NAME: ${{ secrets.STAGING_NEW_RELIC_APP_NAME }} STAGING_OSMCHA_PG_USER: ${{ secrets.STAGING_OSMCHA_PG_USER }} diff --git a/values.staging.template.yaml b/values.staging.template.yaml index ee81f010..b8eefed8 100644 --- a/values.staging.template.yaml +++ b/values.staging.template.yaml @@ -344,9 +344,9 @@ osm-seed: tilerDb: enabled: true env: - POSTGRES_HOST: {{STAGING_TILER_DB_HOST}} - POSTGRES_DB: {{STAGING_TILER_DB}} - POSTGRES_USER: {{STAGING_TILER_DB_USER}} + POSTGRES_HOST: staging-tiler-db + POSTGRES_DB: tiler-osm + POSTGRES_USER: postgres POSTGRES_PASSWORD: {{STAGING_TILER_DB_PASSWORD}} POSTGRES_PORT: 5432 # for 20Gi From 51a14e16f3317a499827f83b5c3d999d79857d39 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 15 Mar 2024 18:34:35 -0500 Subject: [PATCH 2/5] Add rapid github action --- .github/workflows/frontend-rapid.yaml | 91 +++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/frontend-rapid.yaml diff --git a/.github/workflows/frontend-rapid.yaml b/.github/workflows/frontend-rapid.yaml new file mode 100644 index 00000000..0ded9cce --- /dev/null +++ b/.github/workflows/frontend-rapid.yaml @@ -0,0 +1,91 @@ +name: Build and Publish Rapid site +on: + push: + branches: + - 'main' + - 'staging' + - 'deploy/rapid' +jobs: + rapid: + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - name: Set environment variables - Staging + if: github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/deploy/rapid' + uses: allenevans/set-env@v2.0.0 + with: + RAPID_BUCKET: rapid-staging.openhistoricalmap.org + CLOUDFRONT_DISTRIBUTION_ID: E12LU6N0NDXVAX + OHM_URL: https://staging.openhistoricalmap.org + OHM_API_URL: https://staging.openhistoricalmap.org + OHM_CLIENT_ID: vwLXYrZ29YiwxWR5LvAcsiG9paLwE7hBod27O-tl16Q + OHM_CLIENT_SECRET: ${{ secrets.STAGING_RAPID_CLIENT_SECRET }} + - name: Set environment variables - Production + if: github.ref == 'refs/heads/main' + uses: allenevans/set-env@v2.0.0 + with: + RAPID_BUCKET: rapid.openhistoricalmap.org + CLOUDFRONT_DISTRIBUTION_ID: E3VOVJ6DH8HALM + OHM_URL: https://www.openhistoricalmap.org + OHM_API_URL: https://www.openhistoricalmap.org + OHM_CLIENT_ID: RIIz9U-oZmYzi_LXCKMHwHPgbJxALWAZRcgk9F8cppk + OHM_CLIENT_SECRET: ${{ secrets.PRODUCTION_RAPID_CLIENT_SECRET }} + - name: Checkout rapid repo + uses: actions/checkout@v2 + with: + repository: OpenHistoricalMap/Rapid + ref: 042f2e27ab0b9a5192549fc17a1ee0f91acab67f + - name: Use Node.js 18 + uses: actions/setup-node@v1 + with: + node-version: 18 + - name: Cache node modules + id: cache-node-modules + uses: actions/cache@v2 + 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: Build rapid frontend + run: | + export OSM_URL=https://www.openstreetmap.org + export OSM_API_URL=https://api.openstreetmap.org + export OSM_CLIENT_ID=O3g0mOUuA2WY5Fs826j5tP260qR3DDX7cIIE2R2WWSc + export OSM_CLIENT_SECRET=b4aeHD1cNeapPPQTrvpPoExqQRjybit6JBlNnxh62uE + files=("modules/services/OsmService.js" "dist/index.html" "dist/latest.html" "index.html") + for file in "${files[@]}"; do + sed -e "s|${OSM_URL}|${OHM_URL}|g" "$file" > tmpfile && mv tmpfile "$file" + sed -e "s|${OSM_API_URL}|${OHM_API_URL}|g" "$file" > tmpfile && mv tmpfile "$file" + sed -e "s|${OSM_CLIENT_ID}|${OHM_CLIENT_ID}|g" "$file" > tmpfile && mv tmpfile "$file" + sed -e "s|${OSM_CLIENT_SECRET}|${OHM_CLIENT_SECRET}|g" "$file" > tmpfile && mv tmpfile "$file" + done + npm run clean + npm run build + npm run dist + sed -e "s|i.client_id|i.client_id,client_secret:\"${OHM_CLIENT_SECRET}\"|g" dist/rapid.min.js > tmpfile && mv tmpfile dist/rapid.min.js + - uses: actions/setup-python@v2 + with: + python-version: '3.8' + - 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() }} + run: | + aws s3 sync dist/ s3://${RAPID_BUCKET}/ + 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 }} From e7cdc78b09427b2299fc4ab5dfc368371203260f Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 15 Mar 2024 18:40:34 -0500 Subject: [PATCH 3/5] Set --acl public-read for rapid bucket files --- .github/workflows/frontend-rapid.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/frontend-rapid.yaml b/.github/workflows/frontend-rapid.yaml index 0ded9cce..6bb898b5 100644 --- a/.github/workflows/frontend-rapid.yaml +++ b/.github/workflows/frontend-rapid.yaml @@ -84,7 +84,7 @@ jobs: - name: Push data to s3 and clean cloudfront cache if: ${{ success() }} run: | - aws s3 sync dist/ s3://${RAPID_BUCKET}/ + aws s3 sync dist/ s3://${RAPID_BUCKET}/ --acl public-read aws cloudfront create-invalidation --distribution-id=${CLOUDFRONT_DISTRIBUTION_ID} --paths=/ env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From 795a3bb8ce1b5a8d6e1f7fd8b76ed6481d31d045 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 15 Mar 2024 18:48:08 -0500 Subject: [PATCH 4/5] Remove deployment rapid in branch deploy/rapid --- .github/workflows/frontend-rapid.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/frontend-rapid.yaml b/.github/workflows/frontend-rapid.yaml index 6bb898b5..6b99c4b5 100644 --- a/.github/workflows/frontend-rapid.yaml +++ b/.github/workflows/frontend-rapid.yaml @@ -4,7 +4,6 @@ on: branches: - 'main' - 'staging' - - 'deploy/rapid' jobs: rapid: runs-on: ubuntu-latest @@ -14,7 +13,7 @@ jobs: with: access_token: ${{ github.token }} - name: Set environment variables - Staging - if: github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/deploy/rapid' + if: github.ref == 'refs/heads/staging' uses: allenevans/set-env@v2.0.0 with: RAPID_BUCKET: rapid-staging.openhistoricalmap.org From ca1016f501dfbab212733d9c978d590830c6beaa Mon Sep 17 00:00:00 2001 From: Rub21 Date: Fri, 15 Mar 2024 18:50:10 -0500 Subject: [PATCH 5/5] Update helm deployment for staging and production --- .github/workflows/chartpress.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/chartpress.yaml b/.github/workflows/chartpress.yaml index 13c7fc87..1d33ac80 100644 --- a/.github/workflows/chartpress.yaml +++ b/.github/workflows/chartpress.yaml @@ -1,5 +1,9 @@ name: Chartpress Publish and Deploy -on: push +on: + push: + branches: + - 'main' + - 'staging' jobs: build: runs-on: ubuntu-20.04