Task/update favicon on custom interfaces (#174) #235
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
name: Deploy NOAA | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main, production ] | |
paths: | |
- noaa-cpfp-point/** | |
jobs: | |
define-environment: | |
name: Set environment | |
runs-on: ubuntu-latest | |
outputs: | |
env_name: ${{ steps.define_environment.outputs.env_name }} | |
steps: | |
- name: Set the environment based on the branch | |
id: define_environment | |
run: | | |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
echo "env_name=staging" >> $GITHUB_OUTPUT | |
elif [ "${{ github.ref }}" = "refs/heads/production" ]; then | |
echo "env_name=production" >> $GITHUB_OUTPUT | |
fi | |
- name: Print the environment | |
run: echo "The environment is ${{ steps.define_environment.outputs.env_name }}" | |
build: | |
runs-on: ubuntu-latest | |
needs: define-environment | |
environment: ${{ needs.define-environment.outputs.env_name }} | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: 'noaa-cpfp-point/' | |
sparse-checkout-cone-mode: true | |
- name: Read Node.js version from .nvmrc | |
id: nvm | |
run: echo "::set-output name=NODE_VERSION::$(cat noaa-cpfp-point/.nvmrc)" | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ steps.nvm.outputs.NODE_VERSION }} | |
- name: Install Yarn | |
run: npm install -g yarn | |
- name: Build for production 🔧 | |
working-directory: ./noaa-cpfp-point | |
run: | | |
echo PUBLIC_URL="${{ vars.PUBLIC_URL_NOAA }}" >> .env | |
echo MAPBOX_ACCESS_TOKEN="${{ secrets.MAP_ACCESS_TOKEN }}" >> .env | |
yarn | |
yarn production | |
env: | |
PUBLIC_URL: ${{ vars.PUBLIC_URL_NOAA }} | |
- name: Upload dist folder | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist_folder | |
path: ./noaa-cpfp-point/dist | |
deploy-staging: | |
needs: | |
- build | |
- define-environment | |
if: github.ref == 'refs/heads/main' | |
environment: ${{ needs.define-environment.outputs.env_name }} | |
permissions: | |
id-token: write | |
contents: read | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Download dist folder | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist_folder | |
path: ./noaa-cpfp-point/dist | |
- name: ConfigureAWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.DEPLOYMENT_ROLE_ARN }} | |
role-session-name: ${{ github.repository_owner}} | |
aws-region: us-west-2 | |
- name: Upload to S3 | |
run: | | |
export PUBLIC_URL=$(echo ${{ vars.PUBLIC_URL_NOAA }} | sed -E 's|^https?://[^/]+/||') | |
echo "PUBLIC_URL=${PUBLIC_URL}" >> $GITHUB_ENV | |
aws s3 sync "./noaa-cpfp-point/dist" s3://ghgc-custom-interfaces-staging/${PUBLIC_URL}/ --cache-control max-age=30,must-revalidate,s-maxage=604800 --delete | |
aws s3 sync "./noaa-cpfp-point/data" s3://ghgc-custom-interfaces-staging/${PUBLIC_URL}/data/ --cache-control max-age=30,must-revalidate,s-maxage=604800 --delete | |
env: | |
PUBLIC_URL: ${{ vars.PUBLIC_URL_NOAA }} | |
- name: Request Invalidation to AWS Cloudfront | |
uses: oneyedev/aws-cloudfront-invalidation@v1 | |
with: | |
distribution-id: ${{ secrets.CF_DISTRIBUTION_ID }} | |
paths: | | |
/ghgcenter/custom-interfaces/* | |
deploy-production: | |
needs: | |
- build | |
- define-environment | |
if: github.ref == 'refs/heads/production' | |
environment: ${{ needs.define-environment.outputs.env_name }} | |
permissions: | |
id-token: write | |
contents: read | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Download dist folder | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist_folder | |
path: ./noaa-cpfp-point/dist | |
- name: ConfigureAWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.DEPLOYMENT_ROLE_ARN }} | |
role-session-name: ${{ github.repository_owner}} | |
aws-region: us-west-2 | |
- name: Upload to S3 | |
run: | | |
export PUBLIC_URL=$(echo ${{ vars.PUBLIC_URL_NOAA }} | sed -E 's|^https?://[^/]+/||') | |
echo "PUBLIC_URL=${PUBLIC_URL}" >> $GITHUB_ENV | |
aws s3 sync "./noaa-cpfp-point/dist" s3://ghgc-custom-interfaces-production/${PUBLIC_URL}/ --cache-control max-age=30,must-revalidate,s-maxage=604800 --delete | |
aws s3 sync "./noaa-cpfp-point/data" s3://ghgc-custom-interfaces-production/${PUBLIC_URL}/data/ --cache-control max-age=30,must-revalidate,s-maxage=604800 --delete | |
env: | |
PUBLIC_URL: ${{ vars.PUBLIC_URL_NOAA }} | |
- name: Request Invalidation to AWS Cloudfront | |
uses: oneyedev/aws-cloudfront-invalidation@v1 | |
with: | |
distribution-id: ${{ secrets.CF_DISTRIBUTION_ID }} | |
paths: | | |
/ghgcenter/custom-interfaces/* |