Skip to content

Watcher

Watcher #120

Workflow file for this run

name: Watcher
on:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch:
env:
WATCHER_SCRIPT: watcher.py
BUILDER_CONFIG_FILE: image-builder.json
jobs:
images-to-update:
runs-on: ubuntu-latest
name: Get images to update
permissions:
contents: read
outputs:
image-list: ${{ steps.get-images.outputs.images }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get all images
id: get-images
run: |
pip install PyGithub
IMAGES=$(python $WATCHER_SCRIPT | tr -d '[:space:]')
echo $IMAGES
echo "images=$IMAGES" >> $GITHUB_OUTPUT
open-pr:
runs-on: ubuntu-latest
needs: images-to-update
strategy:
fail-fast: false
matrix:
images: ${{ fromJson(needs.images-to-update.outputs.image-list) }}
name: Pull request for ${{ matrix.images.image }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
- name: Update image-builder.json
run: |
jq -r '(.[] | select(.context == "${{ matrix.images.context }}") | .tag) |= "${{ matrix.images.tag }}"' $BUILDER_CONFIG_FILE > /tmp/$BUILDER_CONFIG_FILE
mv /tmp/$BUILDER_CONFIG_FILE $BUILDER_CONFIG_FILE
- name: Replace release arg
run: |
sed -i 's/RELEASE="${{ matrix.images.old_tag }}"/RELEASE="${{ matrix.images.tag }}"/g' ${{ matrix.images.context }}/${{ matrix.images.dockerfile }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: 'Bump ${{ matrix.images.context }} to ${{ matrix.images.tag }}'
commit-message: 'Bump ${{ matrix.images.context }} to ${{ matrix.images.tag }}'
body: This PR is auto-generated.
base: master
branch: bump-${{ matrix.images.context }}-to-${{ matrix.images.tag }}
reviewers: rdvencioneck,vlad-she,TakGN