Skip to content

Update GKE EOL file #325

Update GKE EOL file

Update GKE EOL file #325

Workflow file for this run

name: Update GKE EOL file
on:
schedule:
# Runs at midnight UTC every day
- cron: '0 0 * * *'
jobs:
build-and-merge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure all history is fetched for accurate diff
- name: Run the eol script
run: |
# Make the EOL parser script executable and run it
chmod +x ./gcpdiag/lint/gke/eol_parser.sh
bash ./gcpdiag/lint/gke/eol_parser.sh > gcpdiag/lint/gke/eol.yaml
# Check for changes in the EOL YAML file
if ! git diff --exit-code gcpdiag/lint/gke/eol.yaml > /dev/null; then
echo "NEW_EOL_UPDATE=true" >> $GITHUB_ENV # Mark that new EOL updates are available
fi
- name: Commit changes
if: env.NEW_EOL_UPDATE == 'true'
id: commit_changes
run: |
# Set Git config and commit changes if any
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git add gcpdiag/lint/gke/eol.yaml
git commit -m "Update gke/eol.yaml file"
git push origin HEAD:automated-gke-eol-changes # Push the changes to a branch
- name: Create Pull Request
if: success() && env.NEW_EOL_UPDATE == 'true'
id: create_pull_request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create a pull request for the changes
gh pr create --title "Update gke/eol.yaml files" \
--body "Updating gke/eol update with the new eol for GKE clusters" \
--base main \
--head automated-gke-eol-changes \
--label "automerge"
- name: Merge Pull Request
if: success() && env.NEW_EOL_UPDATE == 'true'
run: |
# Retrieve the URL of the newly created pull request.
PR_URL=$(gh pr list --base main --head automated-gke-eol-changes --json url --jq '.[0].url')
# If a pull request URL is found, attempt to merge it.
if [ -n "$PR_URL" ]; then
gh pr merge "$PR_URL" --rebase --auto
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}