ci: test matrix summary #14
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: Deploy | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
entry: [sm, saas] # Add more entries as needed | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# Your deployment step here | |
- name: Deploy to ${{ matrix.entry }} | |
run: | | |
# Your deployment script goes here | |
# Simulate deployment process and create a success/failure status | |
echo "Deploying to ${{ matrix.entry }}" | |
if [ "${{ matrix.entry }}" = "sm" ]; then | |
exit 0 | |
else | |
exit 1 | |
fi | |
- name: Save deployment status | |
if: always() | |
run: | | |
mkdir -p deployment_status | |
echo "${{ matrix.entry }}=${{ job.status }}" > deployment_status/status_${{ matrix.entry }}.txt | |
- name: Upload deployment status artifact | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: deployment-status-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.entry }} | |
path: deployment_status/status_${{ matrix.entry }}.txt | |
summarize: | |
if: always() | |
needs: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: deployment_status | |
- name: Summarize deployment statuses | |
run: | | |
summary="Deployment status summary:\n" | |
for file in deployment_status/**/*.txt; do | |
entry=$(basename "$file" .txt | cut -d'_' -f2) | |
status=$(cat "$file") | |
summary+="$entry: $status\n" | |
done | |
echo "$summary" > summary.txt | |
echo "$summary" | |
# - name: Post summary as a comment | |
# if: github.event_name == 'pull_request' | |
# uses: actions/github-script@v7 | |
# with: | |
# script: | | |
# const fs = require('fs'); | |
# const summary = fs.readFileSync('summary.txt', 'utf8'); | |
# await github.rest.issues.createComment({ | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# issue_number: context.issue.number, | |
# body: summary, | |
# }); |