Wiki source code of Create Automatically Updating Repo in GitHub
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | ### GitHub Actions | ||
2 | |||
3 | The GitHub actions are used for CI purposes. One job is auto update, which can be enabled as follows: | ||
4 | |||
5 | * Repo > Settings > | ||
6 | * General > | ||
7 | * Pull Requests > enable "Allow auto-merge". | ||
8 | * Branches > Add classic branch protection rule | ||
9 | * Branch name pattern: main | ||
10 | * Enable "Require status checks to pass before merging". | ||
11 | * Actions > General > Workflow permissions > enable "Allow GitHub Actions to create and approve pull requests" | ||
12 | * If option is greyed out, then probably the project policy is dictated by the repository policy. Simply do this in repository settings then. | ||
13 | * Copy the workflow file from this project. The key configs are the "permissions" to include "contents: write, pull-requests: write" and the "auto-merge" step. | ||
14 | |||
15 | If you don't need a private module from the same repository, you must delete the "Authenticate for private modules" job. Otherwise, the following steps are necessary: | ||
16 | |||
17 | * GitHub > Profile > Settings > Developer Settings > Personal Access Tokens > Tokens (classic) > Generate new token | ||
18 | * Name: ACTIONS_TOKEN | ||
19 | * Select scopes: "repo" | ||
20 | * Copy the token | ||
21 | * Repo > Settings > Secrets and variables > Actions > New repository secret > | ||
22 | * Name: MY_TOKEN | ||
23 | * You need to set "environment: MY_TOKEN" in the workflow file to use its environment secrets | ||
24 | * Environment Secrets > Add environment secret | ||
25 | * Name: ACTIONS_TOKEN | ||
26 | * Value: | ||
27 | |||
28 | Add this to the workflow file: | ||
29 | |||
30 | - name: Authenticate for private modules | ||
31 | env: | ||
32 | ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }} | ||
33 | run: | | ||
34 | git config --global url."https://${ACTIONS_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/" | ||
35 | go env -w GOPRIVATE=github.com/ocelot-cloud/* | ||
36 | |||
37 | ### Private Go Repository Dependency | ||
38 | |||
39 | If you are developing with Go and need a private repository as a dependency, you need to tell the SDK to use SSH instead of HTTPS to get access. | ||
40 | |||
41 | git config --global url."ssh://git@github.com/".insteadOf "https://github.com/" | ||
42 | go env -w GOPRIVATE=github.com/ocelot-cloud/* |