{"id":13601019,"url":"https://github.com/mvdan/github-actions-golang","last_synced_at":"2025-05-14T22:08:35.542Z","repository":{"id":37095875,"uuid":"206034449","full_name":"mvdan/github-actions-golang","owner":"mvdan","description":"GitHub Actions as CI for Go","archived":false,"fork":false,"pushed_at":"2025-02-11T23:20:26.000Z","size":61,"stargazers_count":1037,"open_issues_count":3,"forks_count":73,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-13T18:44:39.889Z","etag":null,"topics":["cd","ci","github","github-actions","go","golang","modules"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvdan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"mvdan"}},"created_at":"2019-09-03T09:01:45.000Z","updated_at":"2025-03-30T16:52:33.000Z","dependencies_parsed_at":"2024-04-09T23:48:18.723Z","dependency_job_id":"f798a4a4-7541-48a5-8db9-cdc789100fcb","html_url":"https://github.com/mvdan/github-actions-golang","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Fgithub-actions-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Fgithub-actions-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Fgithub-actions-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdan%2Fgithub-actions-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvdan","download_url":"https://codeload.github.com/mvdan/github-actions-golang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235700,"owners_count":22036964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cd","ci","github","github-actions","go","golang","modules"],"created_at":"2024-08-01T18:00:52.762Z","updated_at":"2025-05-14T22:08:30.521Z","avatar_url":"https://github.com/mvdan.png","language":"Go","readme":"# GitHub Actions for Go\n\n[GitHub Actions](https://github.com/features/actions) includes CI/CD for free\nfor Open Source repositories. This document contains information on making it\nwork well for [Go](https://go.dev/). See them [in\naction](https://github.com/mvdan/github-actions-golang/actions):\n\n```yaml\n$ cat .github/workflows/test.yml\non: [push, pull_request]\nname: Test\njobs:\n  test:\n    strategy:\n      matrix:\n        go-version: [1.23.x, 1.24.x]\n        os: [ubuntu-latest, macos-latest, windows-latest]\n    runs-on: ${{ matrix.os }}\n    steps:\n    - uses: actions/checkout@v4\n    - uses: actions/setup-go@v5\n      with:\n        go-version: ${{ matrix.go-version }}\n    - run: go test ./...\n```\n\n## Summary\n\nEach workflow file has a number of jobs, which get run `on` specified events,\nand run concurrently with each other. You can have workflow [status badges](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/adding-a-workflow-status-badge).\n\nEach `job` runs on a configuration `matrix`. For example, we can test two major\nGo versions on three operating systems.\n\nEach job has a number of `steps`, such as installing Go, or checking out the\nrepository's code.\n\nNote that `name` fields are optional.\n\n## FAQs\n\n#### How do I set environment variables?\n\nThey can be set up via `env` for an [entire\nworkflow](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#env),\na job, or for each step:\n\n```yaml\nenv:\n  GOPROXY: \"https://proxy.company.com\"\njobs:\n  [...]\n```\n\n#### How do I set environment variables at run-time?\n\nYou can use [environment files](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#environment-files)\nto set environment variables or add an element to `$PATH`. For example:\n\n```yaml\nsteps:\n- name: Set env vars\n  run: |\n      echo \"CGO_ENABLED=0\" \u003e\u003e $GITHUB_ENV\n      echo \"${HOME}/goroot/bin\" \u003e\u003e $GITHUB_PATH\n```\n\nNote that these take effect for future steps in the job.\n\n#### How do I set up caching between builds?\n\nSince v4, [actions/setup-go](https://github.com/actions/setup-go) caches `GOCACHE`\nand `GOMODCACHE` automatically, using `go.sum` as the cache key.\nYou can turn that off via `cache: false`, and then you may also use your own\ncustom caching, for example to only keep `GOMODCACHE`:\n\n```yaml\n- uses: actions/cache@v3\n  with:\n    path: ~/go/pkg/mod\n    key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}\n    restore-keys: |\n      ${{ runner.os }}-go-\n```\n\nSee [this guide](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows)\nfor more details.\n\n#### How do I run a step conditionally?\n\nYou can use `if` conditionals, using their [custom expression\nlanguage](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs):\n\n```yaml\n- if: github.event_name == 'push' \u0026\u0026 matrix.os == 'ubuntu-latest'\n  run: go run ./endtoend\n```\n\n#### How do I set up a custom build matrix?\n\nYou can [include extra matrix\njobs](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-including-new-combinations),\nand you can [exclude specific matrix\njobs](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-excluding-configurations-from-a-matrix).\n\n#### How do I run multiline scripts?\n\n```yaml\n- name: Series of commands\n  run: |\n    go test ./...\n    go test -race ./...\n```\n\n#### Should I use two workflows, or two jobs on one workflow?\n\nThe biggest difference is the UI; workflow results are shown separately.\nGrouping jobs in workflows can also be useful if one wants to customize the\nworkflow triggers, or to set up dependencies via\n[needs](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds).\n\n#### How do I set up a secret environment variable?\n\nFollow [these steps](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions)\nto set up the secret in the repo's settings. After adding a secret like\n`FOO_SECRET`, use it on a step as follows:\n\n```yaml\n- run: some-command\n  env:\n    FOO_SECRET: ${{ secrets.FOO_SECRET }}\n```\n\n#### How do I install private modules?\n\nIt's possible to install modules from private GitHub repositories without using\nyour own proxy. You'll need to add a\n[personal access token](https://github.com/settings/tokens) as a secret\nenvironment variable, as well as configure\n[GOPRIVATE](https://go.dev/ref/mod#private-modules).\nYou can also directly used the token\n[provided by GitHub](https://docs.github.com/en/enterprise-cloud@latest/actions/security-for-github-actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow)\nin the workflow.\nYou can define anything as username in the URL, it is not taken into account by GitHub.\n\n```yaml\n- name: Configure git for private modules\n  env:\n    TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}\n  run: git config --global url.\"https://user:${TOKEN}@github.com\".insteadOf \"https://github.com\"\n```\n\n```yaml\nenv:\n  GOPRIVATE: \"*.company.com\"\njobs:\n  [...]\n```\n\n#### How do I install Linux packages?\n\nUse `sudo apt`, making sure to only run the step on Linux:\n\n```yaml\n- if: matrix.os == 'ubuntu-latest'\n  run: sudo apt update \u0026\u0026 sudo apt install -y --no-install-recommends mypackage\n```\n\n## Quick links\n\n* Concepts, rate limits, etc: https://docs.github.com/en/actions/writing-workflows\n\n* Syntax and fields reference: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions\n\n* GitHub-hosted runners: https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners\n\n## Caveats\n\n* https://github.com/actions/checkout/issues/135\n\n`git config core.autocrlf` defaults to true, so be careful about CRLF endings in\nyour plaintext `testdata` files on Windows. To work around this, set up the\nfollowing `.gitattributes`:\n\n```gitattributes\n* -text\n```\n","funding_links":["https://github.com/sponsors/mvdan"],"categories":["Go","Repositories"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdan%2Fgithub-actions-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvdan%2Fgithub-actions-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdan%2Fgithub-actions-golang/lists"}