Skip to content

Commit

Permalink
Update matrix logic
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianoertel committed Oct 23, 2024
1 parent 34574d5 commit d782078
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,57 @@ jobs:
steps:
- id: generate-matrix
run: |
defaultEnvironment='{"name":"staging","projectId":"testProjectId","envFileKeyRef":"DOTENV_PRIVATE_KEY_STAGING","firebaseServiceAccountRef":"FIREBASE_SERVICE_ACCOUNT_ADMIN_STAGING"}'
environments='${{ vars.STAGING_ENVIRONMENTS }}'
defaultEnvironment='{
"name": "staging",
"projectId": "${{ secrets.FIREBASE_PROJECT_ID_ADMIN_STAGING }}",
"envFileKeyRef": "DOTENV_PRIVATE_KEY_STAGING",
"firebaseServiceAccountRef": "FIREBASE_SERVICE_ACCOUNT_ADMIN_STAGING"
}'
matrix="[$defaultEnvironment]"
if [ -n "$environments" ]; then
matrix="[$matrix, $environments]"
matrix="$matrix, $environments"
fi
echo "matrix=[$matrix]" >> $GITHUB_OUTPUT
echo "matrix=$(jq -cn --argjson environments "$matrix" '{environments: $environments}')" >> $GITHUB_OUTPUT
# ––––––––––––––––––––––––––––––––––––––––––––––– #
# Build and deploy the application
# ––––––––––––––––––––––––––––––––––––––––––––––– #
build-and-deploy:
needs: [generate-matrix]
name: Build and deploy ${{ matrix.name }}
name: Build and deploy ${{ fromJson(needs.generate-matrix.outputs.matrix).environments[matrix.index].name }}
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
env:
${{ matrix.envFileKeyRef }}: ${{ secrets[matrix.envFileKeyRef] }}
matrix:
environment: ${{ fromJson(needs.generate-matrix.outputs.matrix).environments }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.CI_GITHUB_PAT }}
- name: Get configuration
id: get-config
run: |
config='${{ fromJson(needs.generate-matrix.outputs.matrix).environments[matrix.index] }}'
echo "config=$config" >> $GITHUB_OUTPUT
- name: Use configuration
run: |
projectId=$(echo "${{ steps.get-config.outputs.config }}" | jq -r '.projectId')
envFileKeyRef=$(echo "${{ steps.get-config.outputs.config }}" | jq -r '.envFileKeyRef')
firebaseServiceAccountRef=$(echo "${{ steps.get-config.outputs.config }}" | jq -r '.firebaseServiceAccountRef')
echo "Project ID: $projectId"
echo "Env File Key Ref: $envFileKeyRef"
echo "Firebase Service Account Ref: $firebaseServiceAccountRef"
- name: Setup environment
uses: ./.github/actions/setup-node-environment
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# submodules: true
# token: ${{ secrets.CI_GITHUB_PAT }}

- name: Build application
run: npm run build
# - name: Setup environment
# uses: ./.github/actions/setup-node-environment

- name: Debug
run: |
echo "Matrix: ${{ toJson(matrix) }}"
# - name: Build application
# run: npm run build

# - name: Debug
# run: |
# echo "Matrix: ${{ toJson(matrix) }}"

# - name: Deploy to Firebase Hosting Channel
# id: firebase-deploy-staging
Expand Down

0 comments on commit d782078

Please sign in to comment.