update sources #52
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 sources | |
on: | |
workflow_dispatch: {} | |
schedule: | |
- cron: '0 2 * * 1-5' # every week day at 2AM | |
jobs: | |
image-matrix: | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'openshift-pipelines' | |
outputs: | |
images: ${{ steps.set-matrix.outputs.images }} | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- id: set-matrix | |
run: | | |
echo images="$(make actions/matrix)" >> "${GITHUB_OUTPUT}" | |
cat "${GITHUB_OUTPUT}" | |
update-source: | |
permissions: | |
contents: write | |
pull-requests: write | |
needs: image-matrix | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: ${{ fromJSON(needs.image-matrix.outputs.images) }} | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- run: | | |
make sources/${{ matrix.name }}/upgrade | |
make sources/${{ matrix.name }} | |
- name: Commit new changes | |
run: | | |
git checkout -B actions/update/${{ matrix.name}} | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add ${{ matrix.name }} sources.yaml | |
git commit -m "[bot] Update ${{ matrix.name }}" | |
git push -f origin actions/update/${{ matrix.name }} | |
- name: Create pull request | |
run: | | |
if [ "$(gh pr list --base main --head actions/update/${{ matrix.name }} --json url --jq 'length')" = "0" ]; then | |
echo "creating PR..." | |
gh pr create -B main -H actions/update/${{ matrix.name }} --title "[bot] Update ${{ matrix.name }}" --body "Auto-generated pull request by GitHub actions" | |
else | |
echo "a PR already exists, skipping..." | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |