PROD - Deploy all webs #159
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: PROD - Deploy all webs | |
on: | |
workflow_dispatch: | |
permissions: | |
id-token: write | |
jobs: | |
update-radix-config: | |
runs-on: ubuntu-latest | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
steps: | |
- 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: Promote preprod tag to prod ποΈ | |
if: github.ref == 'refs/heads/main' | |
shell: bash | |
id: modify-radix | |
run: | | |
# Install pre-requisite | |
python3 -m venv venv | |
source venv/bin/activate | |
python -m pip install ruamel.yaml | |
python ci/promoteAllToProduction.py web | |
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 all web sites to production" | |
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: | |
needs: update-radix-config | |
runs-on: ubuntu-latest | |
environment: | |
name: production | |
url: https://equinor.com | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
DOCKER_BUILDKIT: 1 | |
steps: | |
- name: Checkout ποΈ | |
uses: actions/checkout@v3 | |
- name: Get token π | |
id: get-token | |
uses: ./.github/workflows/get-auth-token/ | |
# BACKUP CLUSTER PRODUCTION | |
- name: Deploy to Radix backup π | |
id: deploy-backup | |
uses: equinor/radix-github-actions@master | |
with: | |
args: > | |
create job | |
deploy | |
--token-environment | |
--context production | |
-a equinor-web-sites | |
-e ${{ secrets.ENV }} | |
-f | |
# MAIN CLUSTER PLATFORM2 | |
- name: Deploy to Radix π | |
id: deploy-main | |
uses: equinor/radix-github-actions@master | |
with: | |
args: > | |
create job | |
deploy | |
--token-environment | |
--context platform2 | |
-a equinor-web-sites | |
-e ${{ secrets.ENV }} | |
-f | |
- uses: act10ns/slack@v2 | |
with: | |
status: ${{ job.status }} | |
steps: ${{ toJson(steps) }} | |
if: failure() | |
store-image-tags: | |
needs: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout internal ποΈ | |
id: checkout-internal | |
uses: actions/checkout@v3 | |
with: | |
repository: 'equinor/energyvision-internal' | |
ref: main | |
token: ${{ secrets.PADMS_PAT }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' # Or any version you prefer | |
# Check if this can be removed | |
- name: Install dependencies | |
run: | | |
npm install js-yaml | |
- name: Run script for 'web' | |
run: node ci/storeImageTags.js web | |
- name: Commit and push changes | |
run: | | |
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 | |
git add latest-prod-tags.json | |
git commit -m "Update latest-prod-tags.json with new tags" || echo "No changes to commit" | |
git push |