Skip to content

Commit

Permalink
✨ 👷 ability to deploy to radix from github
Browse files Browse the repository at this point in the history
  • Loading branch information
Brynjulf committed Jan 31, 2024
1 parent d1f2143 commit d60b097
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 0 deletions.
50 changes: 50 additions & 0 deletions config/config_files/workflows/build_deploy_radix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 🛠️ Radix Build & Deploy
on:
workflow_call:
inputs:
environment-name:
description: "The GitHub environment to use this workflow in"
type: string
required: true
secrets:
webhook-url:
required: true
jobs:
build:
environment:
name: ${{ inputs.environment-name }}
name: 🛠️ Build & Deploy
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Login Azure
uses: azure/login@v1
with:
client-id: ${{ vars.CLIENT_ID }}
tenant-id: 3aa4a235-b6e2-48d5-9195-7fcf05b459b0
allow-no-subscriptions: true
- name: Get token
run: |
token=$(az account get-access-token --resource 6dae42f8-4368-4678-94ff-3960e28e3630 --query=accessToken -otsv)
echo "::add-mask::$token"
echo "APP_SERVICE_ACCOUNT_TOKEN=$token" >> $GITHUB_ENV
- name: Create build-deploy pipeline
uses: equinor/radix-github-actions@v1
with:
args: >
create pipeline-job
build-deploy
--application ${{ vars.RADIX_APPLICATION_NAME }}
--branch ${{ github.event.repository.default_branch }}
--follow
--token-environment
notify:
name: Notify on slack
needs: [build]
uses: ./.github/workflows/notify.yaml
with:
environment-name: ${{ inputs.environment-name }}
secrets:
webhook-url: ${{ secrets.webhook-url }}
35 changes: 35 additions & 0 deletions config/config_files/workflows/notify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 💬 Notify
on:
workflow_call:
inputs:
environment-name:
type: string
required: true
secrets:
webhook-url:
required: true
jobs:
slack_notification:
name: 💬 Slack notification
runs-on: ubuntu-latest
steps:
- name: Notify
id: slack
uses: slackapi/[email protected]
with:
payload: |
{
"text": "🚀 New version deployed",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "🚀 ${{ vars.RADIX_APPLICATION_NAME }} - Deployed new version to ${{ inputs.environment-name }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.webhook-url }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
60 changes: 60 additions & 0 deletions config/config_files/workflows/promote.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: 📣 Promote
on:
workflow_call:
inputs:
environment-name:
description: "The GitHub environment to use this workflow in"
type: string
required: true
from-environment:
description: "The Radix environment to promote from"
type: string
required: true
to-environment:
description: "The Radix environment to promote to"
type: string
required: true
secrets:
webhook-url:
required: true
jobs:
promote:
environment:
name: ${{ inputs.environment-name }}
name: 📣 Promote
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Login Azure
uses: azure/login@v1
with:
client-id: ${{ vars.CLIENT_ID }}
tenant-id: 3aa4a235-b6e2-48d5-9195-7fcf05b459b0
allow-no-subscriptions: true
- name: Get token
run: |
token=$(az account get-access-token --resource 6dae42f8-4368-4678-94ff-3960e28e3630 --query=accessToken -otsv)
echo "::add-mask::$token"
echo "APP_SERVICE_ACCOUNT_TOKEN=$token" >> $GITHUB_ENV
- name: Create build-deploy pipeline
uses: equinor/radix-github-actions@v1
with:
args: >
create pipeline-job
promote
--application ${{ vars.RADIX_APPLICATION_NAME }}
--follow
--from-environment ${{ inputs.from-environment }}
--to-environment ${{ inputs.to-environment }}
--token-environment
--use-active-deployment
notify:
name: Notify on slack
needs: [promote]
uses: ./.github/workflows/notify.yaml
with:
environment-name: ${{ inputs.environment-name }}
secrets:
webhook-url: ${{ secrets.webhook-url }}
40 changes: 40 additions & 0 deletions config/config_files/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Push
on:
push:
branch: [main]
workflow_dispatch:
jobs:
lint:
name: 🚑 Lint
uses: ./.github/workflows/lint.yaml
test:
name: 🧪 Test
uses: ./.github/workflows/test.yaml
build_deploy_dev:
name: 🛠️ Build and 🚀 Deploy development to radix
needs: [test, lint]
uses: ./.github/workflows/build_deploy_radix.yaml
with:
environment-name: development
secrets:
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
deploy_staging:
name: 🚀 Promote to staging
needs: [build_deploy_dev]
uses: ./.github/workflows/promote.yaml
with:
environment-name: staging
from-environment: development
to-environment: staging
secrets:
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
deploy_production:
name: 🚀 Promote to production
needs: [deploy_staging]
uses: ./.github/workflows/promote.yaml
with:
environment-name: production
from-environment: staging
to-environment: production
secrets:
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
4 changes: 4 additions & 0 deletions config/github_actions_deployment_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/workflows/build_deploy_radix.yaml
https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/workflows/promote.yaml
https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/workflows/notify.yaml
https://raw.githubusercontent.com/equinor/amplify-components/main/config/config_files/workflows/push.yaml

0 comments on commit d60b097

Please sign in to comment.