{"id":13671124,"url":"https://github.com/messense/huaweicloud-github-runner","last_synced_at":"2025-04-27T14:33:06.086Z","repository":{"id":39587758,"uuid":"380675540","full_name":"messense/huaweicloud-github-runner","owner":"messense","description":"GitHub Action for automatic create and register Huawei Cloud ECS instance as a GitHub Actions self-hosted runner","archived":true,"fork":false,"pushed_at":"2022-05-31T12:34:07.000Z","size":907,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-11T08:43:55.618Z","etag":null,"topics":["github-actions","github-actions-runner"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/messense.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}},"created_at":"2021-06-27T07:13:47.000Z","updated_at":"2024-04-03T05:04:56.000Z","dependencies_parsed_at":"2022-09-20T06:01:15.691Z","dependency_job_id":null,"html_url":"https://github.com/messense/huaweicloud-github-runner","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/messense%2Fhuaweicloud-github-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/messense%2Fhuaweicloud-github-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/messense%2Fhuaweicloud-github-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/messense%2Fhuaweicloud-github-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/messense","download_url":"https://codeload.github.com/messense/huaweicloud-github-runner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251154299,"owners_count":21544476,"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":["github-actions","github-actions-runner"],"created_at":"2024-08-02T09:01:00.106Z","updated_at":"2025-04-27T14:33:05.515Z","avatar_url":"https://github.com/messense.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# On-demand self-hosted [Huawei Cloud](https://www.huaweicloud.com/) ECS runner for GitHub Actions\n\n[![Integration Test](https://github.com/messense/huaweicloud-github-runner/actions/workflows/test.yml/badge.svg)](https://github.com/messense/huaweicloud-github-runner/actions/workflows/test.yml)\n\nStart your [ECS](https://www.huaweicloud.com/product/ecs.html) [self-hosted runner](https://docs.github.com/en/free-pro-team@latest/actions/hosting-your-own-runners) right before you need it.\nRun the job on it.\nFinally, stop it when you finish.\nAnd all this automatically as a part of your GitHub Actions workflow.\n\nThis project was forked from [machulav/ec2-github-runner](https://github.com/machulav/ec2-github-runner) with modifications.\n\nSee [below](#example) the YAML code of the depicted workflow. \n\n## Usage\n\n### How to start\n\nUse the following steps to prepare your workflow for running on your ECS self-hosted runner:\n\n**1. Prepare [IAM](https://console.huaweicloud.com/iam) user with access keys**\n\n1. Create new acccess keys for the new or an existing IAM user with required [ECS server adminstrator](https://support.huaweicloud.com/productdesc-ecs/ecs_01_0059.html#section5) permisions.\n2. Add the keys to GitHub secrets\n\n**2. Prepare GitHub personal access token**\n\n1. Create a new [GitHub personal access token](https://github.com/settings/tokens) with the repo scope. The action will use the token for self-hosted runners management in the GitHub account on the repository level.\n2. Add the token to GitHub secrets.\n\n**3. Prepare ECS image (optional)**\n\n1. You can use the default Ubuntu/CentOS image, but it's recommended to create your own image with Docker pre-installed.\n\n**4. Prepare VPC with subnet and security group**\n\n1. Create a new VPC and a new subnet in it. Or use the existing VPC and subnet.\n2. Create a new security group for the runners in the VPC.\n   Only the outbound traffic on port 443 should be allowed for pulling jobs from GitHub.\n   No inbound traffic is required.\n\n**5. Configure the GitHub workflow**\n\n1. Create a new GitHub Actions workflow or edit the existing one.\n2. Use the documentation and example below to configure your workflow.\n3. Please don't forget to set up a job for removing the ECS instance at the end of the workflow execution.\n   Otherwise, the ECS instance won't be removed and continue to run even after the workflow execution is finished.\n\n### Inputs\n\n| \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;Name\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; | Required                                            | Description                                                                                                                                                                                                                         |\n| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `mode`                                                                                                                                                                       | Always required.                                    | Specify here which mode you want to use: \u003cbr\u003e - `start` - to start a new runner; \u003cbr\u003e - `stop` - to stop the previously created runner.                                                                                             |\n| `github-token`                                                                                                                                                               | Always required.                                    | GitHub Personal Access Token with the `repo` scope assigned.                                                                                                                                                                        |\n| `huawei-cloud-ak`                                                                                                                                                            | Always required.                                    | Huawei Cloud AK                                                                                                                                                                                                                     |\n| `huawei-cloud-sk`                                                                                                                                                            | Always required.                                    | Huawei Cloud SK                                                                                                                                                                                                                     |\n| `project-id`                                                                                                                                                                 | Always required.                                    | Huawei Cloud project id                                                                                                                                                                                                             |\n| `availability-zone`                                                                                                                                                          | Alwasy required.                                    | ECS availability zone                                                                                                                                                                                                               |\n| `ecs-image-id`                                                                                                                                                               | Required if you use the `start` mode.               | [ECS Image](https://www.huaweicloud.com/product/ims.html) Id. \u003cbr\u003e\u003cbr\u003e The new runner will be launched from this image. \u003cbr\u003e\u003cbr\u003e The action is compatible with Ubuntu/CentOS images.                                                |\n| `ecs-instance-type`                                                                                                                                                          | Required if you use the `start` mode.               | [ECS Instance Type](https://www.huaweicloud.com/product/ecs/instance-types.html).                                                                                                                                                   |\n| `vpc-id`                                                                                                                                                                     | This input is required if you use the `start` mode. | [VPC](https://www.huaweicloud.com/product/vpc.html) Id                                                                                                                                                                              |\n| `subnet-id`                                                                                                                                                                  | Required if you use the `start` mode.               | VPC Subnet Id. \u003cbr\u003e\u003cbr\u003e The subnet should belong to the same VPC as the specified security group.                                                                                                                                   |\n| `security-group-id`                                                                                                                                                          | Required if you use the `start` mode.               | ECS Security Group Id. \u003cbr\u003e\u003cbr\u003e The security group should belong to the same VPC as the specified subnet. \u003cbr\u003e\u003cbr\u003e Only the outbound traffic for port 443 should be allowed. No inbound traffic is required.                        |\n| `label`                                                                                                                                                                      | Required if you use the `stop` mode.                | Name of the unique label assigned to the runner. \u003cbr\u003e\u003cbr\u003e The label is provided by the output of the action in the `start` mode. \u003cbr\u003e\u003cbr\u003e The label is used to remove the runner from GitHub when the runner is not needed anymore. |\n| `ecs-instance-id`                                                                                                                                                            | Required if you use the `stop` mode.                | ECS Instance Id of the created runner. \u003cbr\u003e\u003cbr\u003e The id is provided by the output of the action in the `start` mode. \u003cbr\u003e\u003cbr\u003e The id is used to terminate the ECS instance when the runner is not needed anymore.                    |\n| `count`                                                                                                                                                                      | Not required                                        | ECS instance count, defaults to 1                                                                                                                                                                                                   |\n| `server-tags`                                                                                                                                                                | Optional. Used only with the `start` mode.          | Specifies tags to add to the ECS instance and any attached storage. \u003cbr\u003e\u003cbr\u003e This field is a stringified JSON array of tag objects, each containing a `key` and `value` field (see example below).                                  |\n\nThe runners created by this action will have `self-hosted` and `huaweicloud` labels, you can use them in `runs-on`.\n\n## Example\n\nThe workflow showed in the picture above and declared in `do-the-job.yml` looks like this:\n\n```yaml\nname: do-the-job\non: [push]\n\njobs:\n  start-runner:\n    name: Start self-hosted ECS runner\n    runs-on: ubuntu-latest\n    outputs:\n      label: ${{ steps.start-ecs-runner.outputs.label }}\n      ecs-instance-id: ${{ steps.start-ecs-runner.outputs.ecs-instance-id }}\n    steps:\n      - uses: actions/checkout@v2\n      - name: Start ECS runner\n        id: start-ecs-runner\n        uses: messense/huaweicloud-github-runner@main\n        with:\n          mode: start\n          github-token: ${{ secrets.GH_PAT }}\n          huawei-cloud-ak: ${{ secrets.HUAWEI_CLOUD_AK }}\n          huawei-cloud-sk: ${{ secrets.HUAWEI_CLOUD_SK }}\n          project-id: ${{ secrets.PROJECT_ID }}\n          availability-zone: ap-southeast-1b\n          ecs-image-id: 93b1fc8d-ee4e-4126-950e-8f4404408acc\n          ecs-instance-type: kc1.large.2\n          vpc-id: ${{ secrets.VPC_ID }}\n          subnet-id: ${{ secrets.SUBNET_ID }}\n          security-group-id: ${{ secrets.SECURITY_GROUP_ID }}\n  do-the-job:\n    name: Do the job on the runner\n    needs: start-runner\n    runs-on: ${{ needs.start-runner.outputs.label }}\n    steps:\n      - name: Hello World\n        run: echo 'Hello World!'\n  stop-runner:\n    name: Stop self-hosted ECS runner\n    needs: [start-runner, do-the-job]\n    runs-on: ubuntu-latest\n    if: ${{ always() }}\n    steps:\n      - uses: actions/checkout@v2\n      - name: Stop ECS runner\n        if: ${{ needs.start-runner.outputs.ecs-instance-id }}\n        uses: messense/huaweicloud-github-runner@main\n        with:\n          mode: stop\n          github-token: ${{ secrets.GH_PAT }}\n          huawei-cloud-ak: ${{ secrets.HUAWEI_CLOUD_AK }}\n          huawei-cloud-sk: ${{ secrets.HUAWEI_CLOUD_SK }}\n          project-id: ${{ secrets.PROJECT_ID }}\n          availability-zone: ap-southeast-1b\n          label: ${{ needs.start-runner.outputs.label }}\n          ecs-instance-id: ${{ needs.start-runner.outputs.ecs-instance-id }}\n```\n\n## License\n\nThis work is released under the MIT license. A copy of the license is provided in the [LICENSE](./LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmessense%2Fhuaweicloud-github-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmessense%2Fhuaweicloud-github-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmessense%2Fhuaweicloud-github-runner/lists"}