PREPROD - Build & Deploy all webs #359
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: PREPROD - Build & Deploy all webs | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- 'web/**' | |
- '!web/README.md' | |
- '!web/.storybook/**' | |
- '!web/.gitignore' | |
- '!web/jest.config.cjs' | |
- '!web/jest.setup.ts' | |
- './FeatureFlags.js' | |
- '!web/components/README.md' | |
permissions: | |
id-token: write | |
packages: write | |
jobs: | |
update-radix-config: | |
runs-on: ubuntu-latest | |
environment: | |
name: preprod | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
steps: | |
- name: Checkout ποΈ | |
uses: actions/checkout@v3 | |
- name: Set image tag π· | |
shell: bash | |
id: set-default-image-tag | |
run: | | |
echo "IMAGE_TAG_SHA=$(git rev-parse --short=12 ${GITHUB_SHA})" >> $GITHUB_ENV | |
- name: Checkout internal ποΈ | |
id: checkout-internal | |
uses: actions/checkout@v3 | |
with: | |
repository: 'equinor/energyvision-internal' | |
ref: main | |
token: ${{ secrets.PADMS_PAT }} # Replace with ssh as per https://stackoverflow.com/questions/60222741/github-actions-and-git-clone-issue | |
- name: Modify radixconfig tag for preprod on main branch ποΈ | |
if: github.ref == 'refs/heads/main' | |
shell: bash | |
id: modify-radix | |
run: | | |
# Install pre-requisite | |
python -m pip install --user ruamel.yaml | |
python ci/upgradeEnvironment.py web ${{ env.IMAGE_TAG_SHA }} ${{ secrets.ENV }} | |
git config --global user.name 'github' | |
git config --global user.email '[email protected]' | |
git remote set-url origin https://x-access-token:${{ secrets.PADMS_PAT }}@github.com/equinor/energyvision-internal | |
if [[ `git status --porcelain` ]] | |
then | |
git commit -am "π Deploy webs to preprod with tag ${{ env.IMAGE_TAG_SHA }}" --allow-empty | |
git pull --rebase origin main | |
git push origin HEAD:main | |
fi | |
- uses: act10ns/slack@v2 | |
with: | |
status: ${{ job.status }} | |
steps: ${{ toJson(steps) }} | |
if: failure() | |
deploy-secret: | |
needs: update-radix-config | |
runs-on: ubuntu-latest | |
environment: | |
name: preprod | |
url: https://web-secret-energyvision-preprod.radix.equinor.com/ | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
DOCKER_BUILDKIT: 1 | |
steps: | |
- name: Checkout ποΈ | |
uses: actions/checkout@v3 | |
- id: deploy-secret | |
uses: ./.github/workflows/deploy-websites/ | |
with: | |
imageName: ghcr.io/equinor/energyvision/web-secret | |
projectId: w3b4om14 | |
datasetName: secret | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
sanityApiToken: ${{ secrets.SANITY_API_SECRET_TOKEN }} | |
sanityPreviewSecret: ${{ secrets.SANITY_STUDIO_SECRET_PREVIEW_SECRET }} | |
algoliaAppId: ${{ secrets.ALGOLIA_APP_ID }} | |
algoliaApiKey: ${{ secrets.ALGOLIA_SEARCH_API_KEY }} | |
environment: ${{ secrets.ENV }} | |
archiveContentLink: ${{ vars.ARCHIVE_CONTENT_LINK }} | |
- uses: act10ns/slack@v2 | |
with: | |
status: ${{ job.status }} | |
steps: ${{ toJson(steps) }} | |
if: failure() | |
read-satellites: | |
runs-on: ubuntu-latest | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: set-matrix | |
name: Read from satellites.json | |
run: | | |
MATRIX=$(cat satellites.json) | |
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT | |
- uses: act10ns/slack@v2 | |
with: | |
status: ${{ job.status }} | |
steps: ${{ toJson(steps) }} | |
if: failure() | |
deploy-all-sites: | |
needs: [update-radix-config, read-satellites] | |
runs-on: ubuntu-latest | |
environment: | |
name: preprod | |
strategy: | |
matrix: | |
dataset: ${{ fromJson(needs.read-satellites.outputs.matrix) }} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
DOCKER_BUILDKIT: 1 | |
steps: | |
- name: Checkout π | |
uses: actions/checkout@v3 | |
- name: Deploy website π | |
id: deploy-website | |
uses: ./.github/workflows/deploy-websites/ | |
with: | |
imageName: ghcr.io/equinor/energyvision/web-${{ matrix.dataset }} | |
datasetName: ${{ matrix.dataset }} | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
sanityApiToken: ${{ secrets.SANITY_API_TOKEN }} | |
sanityPreviewSecret: ${{ secrets.SANITY_STUDIO_PREVIEW_SECRET }} | |
algoliaAppId: ${{ secrets.ALGOLIA_APP_ID }} | |
algoliaApiKey: ${{ secrets.ALGOLIA_SEARCH_API_KEY }} | |
dynatraceEnvironment: ${{ secrets.DYNATRACE_ENVIRONMENT }} | |
dynatracePaaSToken: ${{ secrets.DYNATRACE_PAAS_TOKEN }} | |
dynatraceImage: ${{ secrets.DYNATRACE_PREPROD_IMAGE }} | |
environment: ${{ secrets.ENV }} | |
archiveContentLink: ${{ vars.ARCHIVE_CONTENT_LINK }} | |
- uses: act10ns/slack@v2 | |
with: | |
status: ${{ job.status }} | |
steps: ${{ toJson(steps) }} | |
if: failure() |