Create Automatically Updating Repo in GitHub

Version 2.2 by chrisby on 2025/04/22 14:13
Warning
For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

GitHub Actions

The GitHub actions are used for CI purposes. One job is auto update, which can be enabled as follows:

  • Repo > Settings >
    • General >
      • Pull Requests > enable "Allow auto-merge".
      • Branches > Add classic branch protection rule
        • Branch name pattern: main
        • Enable "Require status checks to pass before merging".
    • Actions > General > Workflow permissions > enable "Allow GitHub Actions to create and approve pull requests"
      • If option is greyed out, then probably the project policy is dictated by the repository policy. Simply do this in repository settings then.
  • 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.

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:

  • GitHub > Profile > Settings > Developer Settings > Personal Access Tokens > Tokens (classic) > Generate new token
    • Name: ACTIONS_TOKEN
    • Select scopes: "repo"
    • Copy the token
  • Repo > Settings > Secrets and variables > Actions > New repository secret >
    • Name: MY_TOKEN
      • You need to set "environment: MY_TOKEN" in the workflow file to use its environment secrets
    • Environment Secrets > Add environment secret
      • Name: ACTIONS_TOKEN
      • Value: Failed to execute the [html] macro. Cause: [When using HTML content inline, you can only use inline HTML content. Block HTML content (such as tables) cannot be displayed. Try leaving an empty line before and after the macro.]. Click on this message for details.

Add this to the workflow file:

- name: Authenticate for private modules
        env:
         ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
       run: |
         git config --global url."https://${ACTIONS_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/"
         go env -w GOPRIVATE=github.com/ocelot-cloud/*

Private Go Repository Dependency

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.

git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"
go env -w GOPRIVATE=github.com/ocelot-cloud/*