Run all distros - FOG install tests #8
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: Run all distros - FOG install tests | |
on: | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
actions: write | |
contents: write | |
jobs: | |
get-all-distros-matrix: | |
runs-on: ubuntu-22.04 | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set matrix of distros | |
id: set-matrix | |
run: | | |
cd .github/workflows/ | |
json_array=$(jq -n '[]') | |
for distro_file in $(ls distro_*); do | |
json_array=$(echo "$json_array" | jq --arg distro "$distro_file" '. + [$distro]') | |
done | |
matrix=$(echo "{\"distros\": $json_array}" | jq -c .) | |
echo "matrix=$matrix" >> $GITHUB_OUTPUT | |
run-distro: | |
needs: get-all-distros-matrix | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
${{ fromJson(needs.get-all-distros-matrix.outputs.matrix) }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run all distros | |
run: gh workflow run ${{ matrix.distros }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
check-if-successful: | |
needs: [get-all-distros-matrix, run-distro] | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
${{ fromJson(needs.get-all-distros-matrix.outputs.matrix) }} | |
steps: | |
- name: Wait a minute for the runs to start | |
run: sleep 60 | |
- name: Get run IDs | |
run: | | |
run_id=$(gh run list --repo ${{ github.repository }} --workflow ${{ matrix.distros }} --json databaseId --limit 1 | jq -r '.[0].databaseId') | |
echo "RUN_ID=$run_id" >> $GITHUB_ENV | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check if distro workflow passed or failed | |
run: | | |
run_status="" | |
while [[ $run_status != "success" && $run_status != "failure" ]]; do | |
sleep 15 | |
run_status=$(gh run view --repo ${{ github.repository }} ${{ env.RUN_ID }} --exit-status --json conclusion | jq -r '.conclusion') | |
done | |
if [[ $run_status == "failure" ]]; then | |
exit 1 | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |