Skip to content

rerun failed jobs #1572

rerun failed jobs

rerun failed jobs #1572

Workflow file for this run

name: rerun failed jobs
on:
workflow_dispatch:
inputs:
run_id:
description: "run id"
required: true
type: string
max_attempts:
description: "max attempts, default is 3"
required: false
default: "3"
type: string
schedule:
- cron: "0 16 * * *"
jobs:
rerun:
if: ${{ github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: re-run failed jobs
run: |
run=`curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.inputs.run_id }}`
status=`jq -r '.conclusion' <<< "$run"`
run_attempt=`jq -r '.run_attempt' <<< "$run"`
if [[ "$status" == "failure" && "$run_attempt" -lt ${{ github.event.inputs.max_attempts }} ]]; then
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.inputs.run_id }}/rerun-failed-jobs
fi
clean:
name: Clean resource
runs-on: ubuntu-latest
if: ${{ github.event_name == 'schedule' }}
defaults:
run:
working-directory: packages/tests
env:
M365_ACCOUNT_NAME: "[email protected]"
M365_ACCOUNT_PASSWORD: ${{ secrets.TEST_M365_PASSWORD }}
M365_DISPLAY_NAME: "ttktest"
M365_USERNAME_2: "[email protected]"
M365_USERNAME_3: "[email protected]"
M365_USERNAME_4: "[email protected]"
CLEAN_CLIENT_ID: ${{ secrets.TEST_CLEAN_CLIENT_ID }}
CLEAN_CLIENT_SECRET: ${{ secrets.CLEAN_CLIENT_SECRET }}
CLEAN_TENANT_ID: ${{ secrets.TEST_CLEAN_TENANT_ID }}
AZURE_TENANT_ID: ${{ secrets.TEST_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.TEST_SUBSCRIPTION_ID }}
AZURE_ACCOUNT_NAME: ${{ secrets.TEST_USER_NAME }}
AZURE_ACCOUNT_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
MAIL_API_KEY: ${{ secrets.MAIL_API_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/[email protected]
with:
node-version: 14
- name: Install npm packages
run: |
npm install
- name: Clean resource
if: always()
run: |
npx ts-node src/scripts/clean.ts
- name: Switch M365 account
run: |
username='${{ env.M365_USERNAME_2 }}'
echo "M365_ACCOUNT_NAME=$username" >> $GITHUB_ENV
- name: Clean resource
if: always()
run: |
npx ts-node src/scripts/clean.ts
- name: Switch M365 account
run: |
username='${{ env.M365_USERNAME_3 }}'
echo "M365_ACCOUNT_NAME=$username" >> $GITHUB_ENV
- name: Clean resource
if: always()
run: |
npx ts-node src/scripts/clean.ts
- name: Switch M365 account
run: |
username='${{ env.M365_USERNAME_4 }}'
echo "M365_ACCOUNT_NAME=$username" >> $GITHUB_ENV
- name: Clean resource
if: always()
run: |
npx ts-node src/scripts/clean.ts