Update workflow #4
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: Update workflow | |
on: | |
workflow_dispatch: | |
inputs: | |
name: | |
description: "The workflow to update (with .yml)" | |
required: true | |
default: "work.yml" | |
page: | |
description: "Page of the repository list to check (currently 1-3)" | |
required: true | |
default: "1" | |
jobs: | |
repositories: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.search-repos.outputs.matrix }} | |
name: List repositories (page ${{ github.event.inputs.page }}) | |
steps: | |
- name: Check actor permission | |
uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0 | |
with: | |
require: admin | |
- name: Create output matrix | |
id: search-repos | |
# This is a simple curl to fetch the list of repos containing a file and extracting the repo names | |
run: | | |
REPOS=$(curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/orgs/${{ github.repository_owner }}/repos?per_page=100&page=${{ github.event.inputs.page }}" | jq -c 'map(.name)') | |
if echo "$REPOS" | grep -q "plugin"; then | |
echo "matrix=$REPOS" >> $GITHUB_OUTPUT | |
else | |
echo "Le mot 'plugin' n'est pas présent dans la liste des répertoires." | |
fi | |
dispatch: | |
runs-on: ubuntu-latest | |
needs: repositories | |
strategy: | |
fail-fast: false | |
matrix: | |
repositories: ${{ fromJSON(needs.repositories.outputs.matrix) }} | |
name: dispatch ${{ github.event.inputs.name }} | |
steps: | |
- name: Checkout target repository | |
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
with: | |
path: target | |
repository: ${{ github.repository_owner }}/${{ matrix.repositories }} | |
- name: Check ${{ github.event.inputs.name }} file existence | |
id: check_file_existence | |
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 | |
with: | |
files: target/.github/workflows/${{ github.event.inputs.name }} | |
- name: Checkout source repository | |
if: steps.check_file_existence.outputs.files_exists == 'true' | |
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
with: | |
path: source | |
- name: Copy workflow | |
if: steps.check_file_existence.outputs.files_exists == 'true' | |
run: cp ./source/workflow-templates/${{ github.event.inputs.name }} ./target/.github/workflows | |
- name: Create Pull Request | |
if: steps.check_file_existence.outputs.files_exists == 'true' | |
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v4 | |
with: | |
body: Automated update of the ${{ github.event.inputs.name }} workflow from https://github.com/${{ github.repository }} | |
branch: feat/workflow-auto-update-${{ github.event.inputs.name }} | |
commit-message: Updating ${{ github.event.inputs.name }} workflow from template | |
committer: Jeedom bot <[email protected]> | |
author: Jeedom bot <[email protected]> | |
path: target | |
signoff: true | |
title: Updating ${{ github.event.inputs.name }} workflow from template | |
labels: dependencies | |
token: ${{ secrets.TEMPLATE_WORKFLOW_DISPATCH_PAT }} |