GitHub Action
Automate Updatecli with GitHub Action
Description
Updatecli is better when executed regularly so let see how to use this GitHub Action install Updatecli in your GitHub runner so you can use it.
Migration
From V1 to v2
The updatecli action v1 was a "Github Action" of type docker. While It was easier to start with, that type of Github Action runs in a docker container and so in a fully isolated environment. We noticed that in many situations, updatecli was used with other tools hence the need to switch to a javascript GitHub action. That second type of GitHub action can install updatecli directly on the Github Action runner. Now, the goal of this GitHub action evolved from running updatecli to installing updatecli.
Parameter
version
version
: Specify the Updatecli version to install. Accepted values are any valid releases such as "v0.25.0". Default value is set to the latest updatecli version
Required: false
Example
The current example is inspired from the repository jenkins-infra/jenkins-infra.
Once you have your update strategy configuration in the directory ./updatecli/updatecli.d
, then you need following files in order to run updatecli from Github Action.
./updatecli/values.yaml
---
github:
user: "GitHub Actions Bot"
email: "bots@udpatecli.io"
username: "github-actions"
token: "UPDATECLI_GITHUB_TOKEN"
./github/workflows/updatecli.yaml
---
name: "Updatecli"
on:
workflow_dispatch:
schedule:
# * is a special character in YAML so you have to quote this string
# Run once a day
- cron: '0 0 * * *'
permissions:
contents: "write"
pull-requests: "write"
jobs:
updatecli:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
- name: Install Updatecli in the runner
uses: updatecli/updatecli-action@v2
- name: Run Updatecli in Dry Run mode
run : "updatecli diff --config ./updatecli/updatecli.d --values updatecli/values.yaml"
env:
UPDATECLI_GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Run Updatecli in apply mode
run : "updatecli apply --config ./updatecli/updatecli.d --values updatecli/values.yaml"
env:
UPDATECLI_GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
IMPORTANT:Environment variables starting with GITHUB_
are reserved by GitHub Action