This repository contains a number of github actions, which perform routine maintenance tasks for a variety of repositories, mostly for the knative org. In particular, this repo exists separately from other repos like https://github.com/knative/test-infra to enable using repository secrets to hold an access token for creating automated PRs.
If you want to run a job periodically against a repo, the
workload-templates
folder holds all the template actions which are copied to all the repos in
Knative using the update-actions workflow in this repo.
To add a repository here, there are two requirements:
-
Add an entry to
repos.yamlcontaining an entry like this:- # name is the repository to operate on, think: https://github.com/{name}.git name: 'knative/pkg' # meta-organization is the github organization from which to sync Github # actions, think: https://github.com/{meta-organization}/hack # Actions are pulled from the workflow-templates directory. meta-organization: 'knative' # fork is the name of the fork to push to (otherwise a branch on the # main repo is used) fork: 'knative-automation/pkg' # channel is the channel on knative.slack.com to post when these actions fail. # These can be a direct-message to a username if prefixed with `@` channel: 'serving-api' # The list of users to which the PR should be `/assign` (only matters for Prow) # These should bias toward Github teams, but must exist within the target # organization (so knative[-sandbox] should use the team in their respective org). assignees: knative/foo-wg-leads
-
github.com/{fork}.gitmust be a fork of{name}(if specified) andknative-automationmust have push access. -
Repos can also optionally exclude certain jobs by adding their name to the appropriate
{foo}-exclude.yamlfile.
This repo exists to run GitHub Actions to create automated management PRs against other repos in Knative. To add a new automated PR workflow (or update one of the existing workflows), it's worth understanding the different components in this repo:
-
.github/workflowscontains the actual GitHub Actions, in the Actions yaml format. These are (mostly) generated from theactionsdirectories mentioned below, but a few are hand-maintained. For the generated workflows, rungo run ./cmd/gen-actionsat the root of the repo to regnerate the files, which will need to be checked in / PR'ed if changed. -
actionscontains a set of GitHub Actions, either as Dockerfile actions or Javascript actions. Each directory underactionsshould contain the following:-
action.yaml-- GitHub actions configuration. This file makes the directory an action. -
Dockerfile(and probablyentrypoint.sh) for Docker-based Actions ORindex.jsandpackage-lock.jsonet al for Javascript actions -
If you want the action to be run against each repo configured in
repos.yaml, add anauto-apply.yaml(schema here). This will cause thegen-actionstool (see below) to generate agithub/workflowsfile which will fan out your command to all repos.It's expected that an auto-apply action will modify the checked-out workspace; these changes will export a
create_prvariable (set totrueif a PR shoud be created) and optionally alogoutput.
-
-
cmd/gen-actionscontains a script (main.go) and a template {actions_template.yaml) for generating fan-out PR generation workflows for all theactionsdirectories which include anauto-apply.yaml.The parameters set in
auto-apply.yamlare passed in to theactions_template.yaml, along with agithubformatting function which passes through the remianing arguments to the GitHub Actions templating system (both use the same{{...}}syntax for templating, so any GitHub templating needs to be escaped from the Go templates).This script should stay fairly short; it's written in Go for two reasons:
- Go is a common language across Knative, and has sufficiently rich templating
- Using Go enables the script to work even on Windows machines, which is a nice benefit