{"id":25828159,"url":"https://github.com/basemax/github-actions-compile-golang","last_synced_at":"2026-04-16T03:31:48.622Z","repository":{"id":279544610,"uuid":"937212921","full_name":"BaseMax/github-actions-compile-golang","owner":"BaseMax","description":"Automatically compile and test a simple Go program using GitHub Actions whenever changes are pushed or a pull request is created to the main branch. The action installs Go, compiles the Go code, and runs the resulting program, ensuring it functions as expected without manual intervention.","archived":false,"fork":false,"pushed_at":"2025-02-23T18:53:35.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T05:55:48.216Z","etag":null,"topics":["cd","ci","ci-cd","cicd-go","cicd-golang","github-action","github-actions","github-actions-go","github-actions-golang","go","go-githubaction","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaseMax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2025-02-22T15:53:24.000Z","updated_at":"2025-02-25T17:08:03.000Z","dependencies_parsed_at":"2025-02-26T05:55:49.552Z","dependency_job_id":"dee89e3d-073d-4b4b-b373-a2c197f635e0","html_url":"https://github.com/BaseMax/github-actions-compile-golang","commit_stats":null,"previous_names":["basemax/github-actions-compile-golang"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fgithub-actions-compile-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fgithub-actions-compile-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fgithub-actions-compile-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2Fgithub-actions-compile-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/github-actions-compile-golang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241189648,"owners_count":19924852,"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","ci-cd","cicd-go","cicd-golang","github-action","github-actions","github-actions-go","github-actions-golang","go","go-githubaction","golang"],"created_at":"2025-02-28T17:23:59.204Z","updated_at":"2026-04-16T03:31:48.575Z","avatar_url":"https://github.com/BaseMax.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Actions to Compile Go Programs\n\nAutomatically compile and test a simple Go program using GitHub Actions whenever changes are pushed or a pull request is created to the `main` branch. The action installs Go, compiles the Go code, and runs the resulting program, ensuring it functions as expected without manual intervention.\n\n## Usage\n\n### 1. Clone the Repository\n\nTo get started, clone this repository to your local machine:\n\n```bash\ngit clone https://github.com/BaseMax/github-actions-compile-golang.git\n```\n\n### 2. GitHub Action Setup\n\nThe GitHub Action is configured to automatically compile the Go program every time a change is pushed to the main branch or a pull request is created.\n\nCreate a new file in the `.github/workflows` directory:\n\n- File name: `c-compile.yml`\n- Action Setup: The action is defined in the `c-compile.yml` file, which runs the following steps:\n  - Checkout code using the `actions/checkout@v3` action.\n  - Install Golang compiler using the apt-get package manager on Ubuntu.\n  - Compile the Go program using `go build -o my_program main.go`.\n  - Run the compiled program and ensure that it works.\n\n### 3. Example Go Program\n\nThe program compiled in this repository is a simple Go program that calculates the factorial of a number.\n\n**Example Go Program (main.go):**\n\n```go\npackage main\n\nimport \"fmt\"\n\nfunc factorial(n int) int {\n    if n == 0 {\n        return 1\n    }\n    return n * factorial(n-1)\n}\n\nfunc main() {\n    fmt.Println(\"Hello, GitHub Actions!\")\n\n    num := 5\n    fmt.Printf(\"Factorial of %d is %d\\n\", num, factorial(num))\n}\n```\n\n### 4. Running the GitHub Action\n\nWhenever you push to the main branch or create a pull request, the GitHub Action will automatically:\n\n- Check out the code.\n- Set up the Golang compiler.\n- Compile the program.\n- Run the program to verify that the compilation was successful.\n- You can view the results of the action under the Actions tab of the GitHub repository.\n\n### GitHub Action Workflow\n\nThe workflow for compiling the C program is defined in the .github/workflows/c-compile.yml file.\n\n```yaml\nname: Compile and Test Go Program\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v3\n\n      - name: Set up Go\n        uses: actions/setup-go@v3\n        with:\n          go-version: '1.24.0'\n\n      - name: Compile Go program\n        run: go build -o my_program main.go\n\n      - name: Run tests\n        run: |\n          if ./my_program; then\n            echo \"Test Passed\"\n          else\n            echo \"Test Failed\"\n            exit 1\n          fi\n```\n\n### Workflow Explanation:\n\n- **Checkout code:** The actions/checkout action checks out the code from the repository.\n- **Set up Go compiler:** Installs Golang compiler to compile the Go program.\n- **Compile Go program:** The `go build` command compiles the main.go file into an executable named my_program.\n- **Run tests:** The program is run, and if the execution is successful, it outputs \"Test Passed\"; otherwise, it outputs \"Test Failed\" and exits with a failure code.\n\n## Contributing\n\nIf you'd like to contribute to this project, feel free to fork the repository, create a pull request with your changes, and submit it for review.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\nMax Base, 2025\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fgithub-actions-compile-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Fgithub-actions-compile-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fgithub-actions-compile-golang/lists"}