Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github actions #12

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
updates:

# Maintain dependencies for Docker Images
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
labels:
- "kind/dependabot"
reviewers:
- "rancher/k3s"

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "kind/dependabot"
reviewers:
- "rancher/k3s"

55 changes: 55 additions & 0 deletions .github/workflows/updatecli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Updatecli: Dependency Management"

on:
schedule:
# Runs at 06 PM UTC
- cron: '0 18 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: write
issues: write
pull-requests: write

jobs:
updatecli:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Install Updatecli
uses: updatecli/updatecli-action@v2

- name: Delete leftover UpdateCLI branches
run: |
gh pr list \
--search "is:closed is:pr head:updatecli_" \
--json headRefName \
--jq ".[].headRefName" | sort -u > closed_prs_branches.txt
gh pr list \
--search "is:open is:pr head:updatecli_" \
--json headRefName \
--jq ".[].headRefName" | sort -u > open_prs_branches.txt
for branch in $(comm -23 closed_prs_branches.txt open_prs_branches.txt); do
if (git ls-remote --exit-code --heads origin "$branch"); then
echo "Deleting leftover UpdateCLI branch - $branch";
git push origin --delete "$branch";
fi
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Apply Updatecli
# Never use '--debug' option, because it might leak the access tokens.
run: "updatecli apply --clean --config ./updatecli/updatecli.d/ --values ./updatecli/values.yaml"
env:
UPDATECLI_GITHUB_ACTOR: ${{ github.actor }}
UPDATECLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}