Check deps #23
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: "Check deps" | |
on: | |
schedule: | |
- cron: '0 12 * * 0' # Run every Sunday at 12:00 PM (noon) | |
workflow_dispatch: # Allows manual triggering | |
# Workflow jobs | |
jobs: | |
check_deps: | |
name: Check deps | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Step 2: Set up Python | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
# Step 3: Install dependencies | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gh | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
# Step 4: Run the Python script | |
- name: Run Python script | |
run: | | |
python update-base-image.py chromium | |
python update-base-image.py chromium-runner | |
python update-deps.py chromium | |
python update-deps.py chromium-runner | |
# Step 5: Configure Git | |
- name: Configure Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
# Step 6: Check if there are any changes | |
- name: Check for changes | |
id: check_changes | |
run: | | |
git diff --exit-code | |
continue-on-error: true | |
# Step 7: Commit and push changes if there are any (failure means, the git index is not clean and there are changes to commit) | |
- name: Commit and push changes | |
if: steps.check_changes.outcome == 'failure' | |
run: | | |
git checkout -b dep-checker-$(date +%Y%m%d%H%M%S) | |
git add . | |
git commit -m "🤖 dependency update" | |
git push origin HEAD | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Step 8: Create a Pull Request and enable auto-merge | |
- name: create pull request | |
if: steps.check_changes.outcome == 'failure' | |
run: | | |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) | |
gh pr create --base main --head $BRANCH_NAME --title '🤖 dependency update' --body 'This PR contains automated changes made by the 🤖 dep-checker workflow.' | |
PR_NUMBER=$(gh pr view --json number -q ".number") | |
gh pr merge $PR_NUMBER --auto --squash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |