Skip to content

Commit

Permalink
Add configuration sync GitHub workflow
Browse files Browse the repository at this point in the history
This adds a workflow that allows us to trigger the configuration sync
task via GitHub Actions rather than needing to do it manually using
kubectl.
  • Loading branch information
thomasleese committed Apr 15, 2024
1 parent f4e4cb7 commit fccd37b
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/configuration-sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Synchronise configuration

on: workflow_dispatch

jobs:
export:
name: Export from production
runs-on: ubuntu-latest

environment: production

steps:
- uses: actions/checkout@v4

- uses: Azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: ./.github/actions/set-kubernetes-credentials
with:
environment: production
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}

- name: Export configuration data
run: |
kubectl exec \
-n tra-production \
deployment/apply-for-qts-production-web \
-- sh -c "cd /app && /usr/local/bin/bundle exec rails configuration_sync:export[data.json]"
- name: Copy configuration data
run: |
kubectl cp \
-n tra-production \
deployment/apply-for-qts-production-web:data.json \
data.json
- name: Upload configuration data
uses: actions/upload-artifact@v4
with:
name: data
path: data.json
retention-days: 3

import:
name: Export from production
runs-on: ubuntu-latest

strategy:
matrix:
environment: [development, test]

environment: ${{ matrix.environment }}

steps:
- uses: actions/checkout@v4

- uses: Azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: ./.github/actions/set-kubernetes-credentials
with:
environment: ${{ matrix.environment }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}

- name: Download configuration data
uses: actions/download-artifact@v4
with:
name: data

- name: Copy configuration data
run: |
kubectl cp \
-n tra-${{ matrix.environment }} \
data.json \
deployment/apply-for-qts-${{ matrix.environment }}-web:data.json
- name: Import configuration data
run: |
kubectl exec \
-n tra-${{ matrix.environment }} \
deployment/apply-for-qts-${{ matrix.environment }}-web \
-- sh -c "cd /app && /usr/local/bin/bundle exec rails configuration_sync:import[data.json]"

0 comments on commit fccd37b

Please sign in to comment.