Refactor nightly

This commit is contained in:
Daniel A. Wozniak 2025-02-25 22:04:22 -07:00
parent bac3653e2f
commit 4e3eb1455e
3 changed files with 69 additions and 65 deletions

View file

@ -16,9 +16,6 @@ on:
type: boolean
default: false
description: Skip running the Salt packages test suite.
schedule:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule
- cron: '0 0 * * *' # Every day at 0AM
env:
COLUMNS: 190
@ -38,65 +35,11 @@ concurrency:
jobs:
workflow-requirements:
name: Check Workflow Requirements
runs-on: ubuntu-22.04
outputs:
requirements-met: ${{ steps.check-requirements.outputs.requirements-met }}
steps:
- name: Check Requirements
id: check-requirements
run: |
if [ "${{ vars.RUN_SCHEDULED_BUILDS }}" = "1" ]; then
MSG="Running workflow because RUN_SCHEDULED_BUILDS=1"
echo "${MSG}"
echo "${MSG}" >> "${GITHUB_STEP_SUMMARY}"
echo "requirements-met=true" >> "${GITHUB_OUTPUT}"
elif [ "${{ github.event.repository.fork }}" = "true" ]; then
MSG="Not running workflow because ${{ github.repository }} is a fork"
echo "${MSG}"
echo "${MSG}" >> "${GITHUB_STEP_SUMMARY}"
echo "requirements-met=false" >> "${GITHUB_OUTPUT}"
elif [ "${{ github.event.repository.private }}" = "true" ]; then
MSG="Not running workflow because ${{ github.repository }} is a private repository"
echo "${MSG}"
echo "${MSG}" >> "${GITHUB_STEP_SUMMARY}"
echo "requirements-met=false" >> "${GITHUB_OUTPUT}"
else
MSG="Running workflow because ${{ github.repository }} is not a fork"
echo "${MSG}"
echo "${MSG}" >> "${GITHUB_STEP_SUMMARY}"
echo "requirements-met=true" >> "${GITHUB_OUTPUT}"
fi
trigger-branch-nightly-builds:
name: Trigger Branch Workflows
if: ${{ github.event_name == 'schedule' && fromJSON(needs.workflow-requirements.outputs.requirements-met) }}
runs-on: ubuntu-22.04
needs:
- workflow-requirements
steps:
- name: Trigger 3006.x branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run nightly.yml --repo ${{ github.repository }} --ref 3006.x
- name: Trigger 3007.x branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run nightly.yml --repo ${{ github.repository }} --ref 3007.x
prepare-workflow:
name: Prepare Workflow Run
runs-on: ubuntu-22.04
environment: ci
if: ${{ fromJSON(needs.workflow-requirements.outputs.requirements-met) }}
needs:
- workflow-requirements
outputs:
changed-files: ${{ steps.process-changed-files.outputs.changed-files }}
salt-version: ${{ steps.setup-salt-version.outputs.salt-version }}
@ -606,8 +549,6 @@ jobs:
runs-on: ubuntu-22.04
environment: nightly
needs:
- workflow-requirements
- trigger-branch-nightly-builds
- prepare-workflow
- pre-commit
- lint

69
.github/workflows/run-nightly.yml vendored Normal file
View file

@ -0,0 +1,69 @@
name: Run Nightly Builds
on:
workflow_dispatch: {}
schedule:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule
- cron: '0 0 * * *' # Every day at 0AM
permissions:
contents: read # for dorny/paths-filter to fetch a list of changed files
pull-requests: read # for dorny/paths-filter to read pull requests
actions: write # to trigger branch nightly builds
jobs:
workflow-requirements:
name: Check Workflow Requirements
runs-on: ubuntu-22.04
outputs:
requirements-met: ${{ steps.check-requirements.outputs.requirements-met }}
steps:
- name: Check Requirements
id: check-requirements
run: |
if [ "${{ vars.RUN_SCHEDULED_BUILDS }}" = "1" ]; then
MSG="Running workflow because RUN_SCHEDULED_BUILDS=1"
echo "${MSG}"
echo "${MSG}" >> "${GITHUB_STEP_SUMMARY}"
echo "requirements-met=true" >> "${GITHUB_OUTPUT}"
elif [ "${{ github.event.repository.fork }}" = "true" ]; then
MSG="Not running workflow because ${{ github.repository }} is a fork"
echo "${MSG}"
echo "${MSG}" >> "${GITHUB_STEP_SUMMARY}"
echo "requirements-met=false" >> "${GITHUB_OUTPUT}"
elif [ "${{ github.event.repository.private }}" = "true" ]; then
MSG="Not running workflow because ${{ github.repository }} is a private repository"
echo "${MSG}"
echo "${MSG}" >> "${GITHUB_STEP_SUMMARY}"
echo "requirements-met=false" >> "${GITHUB_OUTPUT}"
else
MSG="Running workflow because ${{ github.repository }} is not a fork"
echo "${MSG}"
echo "${MSG}" >> "${GITHUB_STEP_SUMMARY}"
echo "requirements-met=true" >> "${GITHUB_OUTPUT}"
fi
trigger-branch-nightly-builds:
name: Trigger Branch Workflows
if: ${{ fromJSON(needs.workflow-requirements.outputs.requirements-met) }}
runs-on: ubuntu-24.04
needs:
- workflow-requirements
strategy:
matrix:
branch: [3006.x, 3007.x, master]
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_SECRET }}
- name: Trigger ${{ matrix.branch }} branch
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
gh workflow run nigthly.yml --repo ${{ github.repository }} --ref ${{ matrix.branch }}

View file

@ -25,9 +25,6 @@ on:
type: boolean
default: false
description: Skip running the Salt packages test suite.
schedule:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule
- cron: '0 0 * * *' # Every day at 0AM
<%- endblock on %>
@ -48,9 +45,6 @@ concurrency:
<%- block pre_jobs %>
<%- include "workflow-requirements-check.yml.jinja" %>
<%- include "trigger-branch-workflows.yml.jinja" %>
<%- endblock pre_jobs %>
<%- block jobs %>