Poll Starter Workflows #3105
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: Poll Starter Workflows | |
on: | |
schedule: | |
- cron: "0 */6 * * *" | |
workflow_dispatch: | |
env: | |
STARTER_WORKFLOW_PATH: "./resources/yaml/" | |
STARTER_WORKFLOW_REPO_BRANCH: "main" | |
permissions: | |
contents: read | |
jobs: | |
poll: | |
permissions: | |
contents: write # for peter-evans/create-pull-request to create branch | |
pull-requests: write # for peter-evans/create-pull-request to create a PR | |
runs-on: ubuntu-latest | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 | |
with: | |
egress-policy: audit | |
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | |
- name: Download starter workflows | |
run: | | |
# get deployment workflows | |
echo "Calling GitHub API for starter workflows" | |
curl \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/actions/starter-workflows/contents/deployments?ref=$STARTER_WORKFLOW_REPO_BRANCH \ | |
| jq -c '.[]' | while read -r workflow; | |
do | |
# extract fields | |
name=$(echo $workflow | jq '.name' -r) | |
downloadUrl=$(echo $workflow | jq '.download_url' -r) | |
sha=$(echo $workflow | jq '.sha' -r) | |
# download workflow if it's an AKS workflow | |
echo "Checking workflow $name" | |
if [[ ( $name == azure-kubernetes-service* ) ]] ; | |
then | |
echo "Downloading starter workflow $name" | |
mkdir -p $STARTER_WORKFLOW_PATH && touch $STARTER_WORKFLOW_PATH$name | |
wget -O $STARTER_WORKFLOW_PATH$name $downloadUrl | |
fi | |
done | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5 | |
with: | |
commit-message: update starter workflows | |
title: Automated Update Starter Workflows | |
body: This is an auto-generated PR. The starter workflow repo has changes not in this repository. Closing this PR stops all future alerts for these particular file changes. | |
branch: starter-workflow-updates |