Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled worklow refactor #67774

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ env:
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

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.repository }}-${{ github.head_ref || github.run_id }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
echo "requirements-met=true" >> "${GITHUB_OUTPUT}"
fi

trigger-branch-nightly-builds:
trigger-builds:
name: Trigger Branch Workflows
if: ${{ fromJSON(needs.workflow-requirements.outputs.requirements-met) }}
runs-on: ubuntu-24.04
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/run-scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Run Scheduled Builds

on:
workflow_dispatch: {}
schedule:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule
- cron: '0 */8 * * *' # Run every 8 hours

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-builds:
name: Trigger Branch Workflows
if: ${{ fromJSON(needs.workflow-requirements.outputs.requirements-met) }}
runs-on: ubuntu-24.04
needs:
- workflow-requirements
environment: workflow-restart
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: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}

- name: Trigger ${{ matrix.branch }} branch
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
gh workflow run nightly.yml --repo ${{ github.repository }} --ref ${{ matrix.branch }}
70 changes: 10 additions & 60 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ name: Scheduled
run-name: "Scheduled (branch: ${{ github.ref_name }})"

on:
schedule:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule
- cron: '0 */8 * * *' # Run every 8 hours
workflow_dispatch:
inputs:
skip-salt-test-suite:
type: boolean
default: false
description: Skip running the Salt test suite.
skip-salt-pkg-test-suite:
type: boolean
default: false
description: Skip running the Salt packages test suite.

env:
COLUMNS: 190
Expand All @@ -20,73 +27,18 @@ env:
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 scheduled builds

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: false

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-scheduled-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 scheduled.yml --repo ${{ github.repository }} --ref 3006.x

- name: Trigger 3007.x branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run scheduled.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 }}
Expand Down Expand Up @@ -571,8 +523,6 @@ jobs:
if: always()
runs-on: ubuntu-22.04
needs:
- workflow-requirements
- trigger-branch-scheduled-builds
- prepare-workflow
- pre-commit
- lint
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/templates/nightly.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ concurrency:

<%- block permissions %>
<{- super() }>
<%- if workflow_slug == "nightly" %>
actions: write # to trigger branch nightly builds
<%- endif %>
<%- endblock permissions %>

<%- block pre_jobs %>
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/templates/scheduled.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ run-name: "<{ workflow_name }> (branch: ${{ github.ref_name }})"
<%- block on %>

on:
schedule:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule
- cron: '0 */8 * * *' # Run every 8 hours
workflow_dispatch:
inputs:
skip-salt-test-suite:
type: boolean
default: false
description: Skip running the Salt test suite.
skip-salt-pkg-test-suite:
type: boolean
default: false
description: Skip running the Salt packages test suite.


<%- endblock %>

Expand All @@ -31,14 +39,9 @@ concurrency:

<%- block permissions %>
<{- super() }>
<%- if workflow_slug == "scheduled" %>
actions: write # to trigger branch scheduled builds
<%- endif %>
<%- endblock permissions %>

<%- block pre_jobs %>

<%- include "workflow-requirements-check.yml.jinja" %>
<%- include "trigger-branch-workflows.yml.jinja" %>

<%- endblock pre_jobs %>
2 changes: 1 addition & 1 deletion .github/workflows/workflow-finished.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ run-name: Workflow Finished ${{ github.event.workflow_run.display_title }} (${{

on:
workflow_run:
workflows: [Nightly, Scheduled, Stage Release]
workflows: [CI, Nightly, Scheduled, Stage Release]
types:
- completed

Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/workflow-pr-finished.yml

This file was deleted.

Loading