Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for windows instances #104

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
96dee15
feat(windows): adds support for windows instances
crunchy234 May 11, 2022
1abbaa2
chore: changes name to match marketplace specs
crunchy234 May 11, 2022
500dd9b
chore: fixes actions deployment issues
crunchy234 May 11, 2022
b9effce
chore: adds some debug
crunchy234 May 11, 2022
617ffe6
feat: adds support for specifying key pair for instance
crunchy234 May 12, 2022
99ca6af
feat: updates runner version to current latest (2.291.1)
crunchy234 May 12, 2022
0022c29
Update dist
May 12, 2022
0d44c7c
fix: only requires base os in start mode
crunchy234 May 12, 2022
695aaf3
Update dist
May 12, 2022
cd87be5
feat: simplifies OS inputs as well as make backwards compatible with …
crunchy234 May 12, 2022
ccfd289
Update dist
May 12, 2022
c770582
fix: fixes new change to ec2-os input
crunchy234 May 12, 2022
5e7952f
Update dist
May 12, 2022
8e5c9d1
docs: updates docs to include how to setup a windows AMI
crunchy234 May 13, 2022
8e5ab1b
Wrong script was run when runnerHomeDir was defined
mhriemers Jul 8, 2022
a6b83f7
npm run package
mhriemers Jul 8, 2022
b947dc2
Merge pull request #1 from mhriemers/patch-1
crunchy234 Jul 10, 2022
da38a64
Update dist
Jul 10, 2022
7be409a
fix: use labels in windows to avoid naming conflict
crunchy234 Apr 17, 2023
5df1ca5
feat: update to use node 16
crunchy234 Apr 17, 2023
f01274c
chore: updates npm packages
crunchy234 Apr 17, 2023
b53ccac
chore: updates to use latest cache package
crunchy234 Apr 17, 2023
41bda0f
ci: use legacy ssl provider
crunchy234 Apr 17, 2023
96b4842
Update dist
Apr 17, 2023
a135f0c
feat: update to use AWS SDK v3
crunchy234 Apr 17, 2023
fed3187
Update dist
Apr 17, 2023
f319abc
Merge remote-tracking branch 'upstream/main' into main
crunchy234 Apr 17, 2023
4b18122
chore: removes deprecated method
crunchy234 Apr 17, 2023
af75bbc
chore: calculate latest dist
crunchy234 May 10, 2023
79e872b
chore: reverts some changes to make this closer to primary repo
crunchy234 May 10, 2023
359f41b
ci: fixes issue running package on ubuntu-latest
crunchy234 May 10, 2023
50424a0
Merge remote-tracking branch 'upstream/main'
crunchy234 Oct 2, 2023
427072b
Update dist
Oct 2, 2023
b41e7a7
feat: updates to aws sdk js v3
crunchy234 Oct 2, 2023
4f34903
chore: updates package lock
crunchy234 Oct 2, 2023
702d348
Update dist
Oct 2, 2023
2b83da5
fix: change way the EC2 client is imported
crunchy234 Oct 2, 2023
469abb8
Update dist
Oct 2, 2023
1e63487
Merge branch 'main-original'
crunchy234 Jun 5, 2024
938ae2c
Update dist
Jun 5, 2024
d833296
feat: adds support for spinning up multiple instances if needed
crunchy234 Jun 5, 2024
a62ccaf
Update dist
Jun 5, 2024
c3e3509
fix: adds new inputs to action.yml
crunchy234 Jun 5, 2024
68cb437
fix: makes sure that instances can be terminated
crunchy234 Jun 5, 2024
53f4dd1
Update dist
Jun 5, 2024
b42ba56
chore: changes back to old input parameter for easy upgrade
crunchy234 Jun 5, 2024
619d526
Merge branch 'main' of github.com-crunchy234:crunchy234/ec2-github-ru…
crunchy234 Jun 5, 2024
58021c4
fix: makes sure output is correct
crunchy234 Jun 5, 2024
69d2d59
Update dist
Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Use the following steps to prepare your workflow for running on your EC2 self-ho

For Amazon Linux 2, it looks like the following:

```
```.shell
sudo yum update -y && \
sudo yum install docker -y && \
sudo yum install git -y && \
Expand All @@ -167,6 +167,22 @@ Use the following steps to prepare your workflow for running on your EC2 self-ho

For other Linux distributions, it could be slightly different.

For a Windows server instance, it looks like the following:

Note: This must be done over RDP since `choco install git` doesn't seem to install correctly over a session manager
connection

```.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco install git

# Remove existing user data run once file (this is so that the user-data being set on instance start actually runs).
rm C:\ProgramData\Amazon\EC2Launch\state\.run-once
```
Note: The `.run-once` file needs to be deleted with every start of the instance you are snapshotting.
If you stop and reboot the instance a few times please make sure you delete the `.run-once` file before creating the
AMI.
Comment on lines +170 to +184
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dmitry1987 This is what you need to do to get the Windows instance to start correctly and run the passed-in user commands.


3. Install any other tools required for your workflow.
4. Create a new EC2 image (AMI) from the instance.
5. Remove the instance if not required anymore after the image is created.
Expand All @@ -193,18 +209,20 @@ Now you're ready to go!
### Inputs

|               Name               | Required | Description |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mode` | Always required. | Specify here which mode you want to use: <br> - `start` - to start a new runner; <br> - `stop` - to stop the previously created runner. |
| `github-token` | Always required. | GitHub Personal Access Token with the `repo` scope assigned. |
| `ec2-image-id` | Required if you use the `start` mode. | EC2 Image Id (AMI). <br><br> The new runner will be launched from this image. <br><br> The action is compatible with Amazon Linux 2 images. |
| `ec2-instance-type` | Required if you use the `start` mode. | EC2 Instance Type. |
| `ec2-os` | Optional. Used only with the `start` mode. | Base OS type of the EC2 image (AMI). This defaults to Linux. The new runner needs to be configured based on OS: <br> - `windows` <br> - `linux` |
| `subnet-id` | Required if you use the `start` mode. | VPC Subnet Id. <br><br> The subnet should belong to the same VPC as the specified security group. |
| `security-group-id` | Required if you use the `start` mode. | EC2 Security Group Id. <br><br> The security group should belong to the same VPC as the specified subnet. <br><br> Only the outbound traffic for port 443 should be allowed. No inbound traffic is required. |
| `label` | Required if you use the `stop` mode. | Name of the unique label assigned to the runner. <br><br> The label is provided by the output of the action in the `start` mode. <br><br> The label is used to remove the runner from GitHub when the runner is not needed anymore. |
| `ec2-instance-id` | Required if you use the `stop` mode. | EC2 Instance Id of the created runner. <br><br> The id is provided by the output of the action in the `start` mode. <br><br> The id is used to terminate the EC2 instance when the runner is not needed anymore. |
| `iam-role-name` | Optional. Used only with the `start` mode. | IAM role name to attach to the created EC2 runner. <br><br> This allows the runner to have permissions to run additional actions within the AWS account, without having to manage additional GitHub secrets and AWS users. <br><br> Setting this requires additional AWS permissions for the role launching the instance (see above). |
| `aws-resource-tags` | Optional. Used only with the `start` mode. | Specifies tags to add to the EC2 instance and any attached storage. <br><br> This field is a stringified JSON array of tag objects, each containing a `Key` and `Value` field (see example below). <br><br> Setting this requires additional AWS permissions for the role launching the instance (see above). |
| `runner-home-dir` | Optional. Used only with the `start` mode. | Specifies a directory where pre-installed actions-runner software and scripts are located.<br><br> |
| `aws-key-pair-name` | Optional. Used only with the `start` mode. | Specifies a key pair to add to the instance when launching it |
| `pre-runner-script` | Optional. Used only with the `start` mode. | Specifies bash commands to run before the runner starts. It's useful for installing dependencies with apt-get, yum, dnf, etc. For example:<pre> - name: Start EC2 runner<br> with:<br> mode: start<br> ...<br> pre-runner-script: \|<br> sudo yum update -y && \ <br> sudo yum install docker git libicu -y<br> sudo systemctl enable docker</pre>
<br><br> |

Expand Down Expand Up @@ -255,6 +273,7 @@ jobs:
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ami-123
ec2-instance-type: t3.nano
ec2-base-os: linux-x64
subnet-id: subnet-123
security-group-id: sg-123
iam-role-name: my-role-name # optional, requires additional permissions
Expand Down
17 changes: 16 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: On-demand self-hosted AWS EC2 runner for GitHub Actions
name: On-demand self-hosted AWS EC2 runner for GitHub Actions with windows support
description: GitHub Action for automatic creation and registration AWS EC2 instance as a GitHub Actions self-hosted runner.
author: Volodymyr Machula
branding:
Expand All @@ -25,6 +25,13 @@ inputs:
EC2 Instance Type.
This input is required if you use the 'start' mode.
required: false
ec2-os:
description: >-
Base OS type of the EC2 image (AMI). The new runner needs to be configured based on OS and architecture:
- 'windows'
- 'linux'
required: false
default: linux
subnet-id:
description: >-
VPC Subnet Id. The subnet should belong to the same VPC as the specified security group.
Expand All @@ -43,6 +50,10 @@ inputs:
The label is used to remove the runner from GitHub when the runner is not needed anymore.
This input is required if you use the 'stop' mode.
required: false
number-of-instances:
description: >-
The number of instances to be launched
required: false
ec2-instance-id:
description: >-
EC2 Instance Id of the created runner.
Expand All @@ -65,6 +76,10 @@ inputs:
description: >-
Directory that contains actions-runner software and scripts. E.g. /home/runner/actions-runner.
required: false
aws-key-pair-name:
description: >-
The AWS Key Pair Name to be associated to the instance
required: false
pre-runner-script:
description: >-
Specifies bash commands to run before the runner starts. It's useful for installing dependencies with apt-get, yum, dnf, etc.
Expand Down
Loading