diff --git a/.github/workflows/configuration-sync.yaml b/.github/workflows/configuration-sync.yaml new file mode 100644 index 0000000000..ff50565985 --- /dev/null +++ b/.github/workflows/configuration-sync.yaml @@ -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]"