{"id":20697480,"url":"https://github.com/epomatti/aws-github-runner-migrations","last_synced_at":"2026-04-05T22:03:44.875Z","repository":{"id":200073179,"uuid":"704729731","full_name":"epomatti/aws-github-runner-migrations","owner":"epomatti","description":"GitHub self-hosted runners migrations with RDS for MySQL","archived":false,"fork":false,"pushed_at":"2024-12-13T19:36:35.000Z","size":176,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-17T18:36:30.550Z","etag":null,"topics":["aws","aws-rds","aws-security","github","github-self-hosted-runner","mount","prisma","rds","terraform","typescript","ubuntu"],"latest_commit_sha":null,"homepage":"","language":"HCL","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/epomatti.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":"2023-10-13T23:35:32.000Z","updated_at":"2024-12-13T19:36:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"b023a06e-ee2a-4e36-aa55-9392683676a0","html_url":"https://github.com/epomatti/aws-github-runner-migrations","commit_stats":null,"previous_names":["epomatti/aws-github-runner-migrations"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Faws-github-runner-migrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Faws-github-runner-migrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Faws-github-runner-migrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Faws-github-runner-migrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epomatti","download_url":"https://codeload.github.com/epomatti/aws-github-runner-migrations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242961747,"owners_count":20213315,"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":["aws","aws-rds","aws-security","github","github-self-hosted-runner","mount","prisma","rds","terraform","typescript","ubuntu"],"created_at":"2024-11-17T00:18:14.667Z","updated_at":"2026-04-05T22:03:44.848Z","avatar_url":"https://github.com/epomatti.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS GitHub Self-Hosted Runners Migrations\n\nDeploying GitHub self-hosted runners to apply migrations to AWS RDS for MySQL.\n\nArchitecture overview:\n\n\u003cimg src=\".assets/aws-gh-runner.png\" /\u003e\n\n## Setup\n\nCreate the `.auto.tfvars` from the template:\n\n```sh\ncp config/local.tfvars .auto.tfvars\n```\n\nSet the EC2 user data file according to your requirements:\n\n```terraform\n# Token for automated register of the GH Runner. Must have administratore read/write permissions\ngh_runner_token = \"github_pat_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\n```\n\nIf you wish to create the application cluster as well, change the variable to `true`:\n\n```terraform\nrds_create_instance        = true\ncreate_application_cluster = true\n```\n\nCreate the infrastructure:\n\n```sh\nterraform init\nterraform apply\n```\n\n## Volume mount\n\n\u003e [!TIP]\n\u003e Device names from EC2 can be different from the actual device. Check the [documentation][7]\n\nIn this project, the EBS volume device name will be `/dev/sdf`, and the block device should be `/dev/nvme1n1`. More about this in the [naming documentation][7].\n\nLogin as `root` to list the drives:\n\n```sh\nfdisk -l\n```\n\nList the available disks with `lsblk`:\n\n```sh\nlsblk\n```\n\nTo determine if the volume is formatted or not, use the `-f` option. If the `FSTYPE` column for the volume (e.g., `/dev/nvme1n1`) is empty, the volume is not formatted. If it shows a file system type (e.g., `ext4`, `xfs`), the volume is already formatted.\n\n```sh\nlsblk -f\n```\n\nTo check it directly, use command below. If the output says `data`, the volume is not formatted. If the output shows a file system type (e.g., `ext4` or `xfs`), the volume is formatted.\n\n```sh\nfile -s /dev/nvme1n1\n```\n\nCheck the mount:\n\n```sh\ndf -h\n```\n\n```sh\nmount -a\n```\n\nFollow the [documentation][6] to format and mount the partition.\n\n\n## GitHub Runner\n\nConnect to the GitHub Runner host.\n\n```sh\naws ssm start-session --target i-00000000000000000\n```\n\nIf creating a new environment, verify that the `userdata` executed correctly and reboot to apply kernel upgrades:\n\n\u003e Should `reboot` automatically\n\n```sh\ncloud-init status\n```\n\nSwitch to root:\n\n```sh\nsudo su -\n```\n\nEnter the `/opt` directory, this is where we'll install the runner agent:\n\n```sh\ncd /opt\n```\n\nEnable the runner scripts to run as root:\n\n```sh\nexport RUNNER_ALLOW_RUNASROOT=\"1\"\n```\n\nAccess the repository Actions section and create a new runner.\n\nMake sure you select the appropriate architecture, which should be `Linux` and `ARM64`.\n\nOnce done, stop the agent and install the runner agent [as a service][5]:\n\n```sh\n./svc.sh install\n./svc.sh start\n./svc.sh status\n```\n\n## GitHub Action\n\nThis repository contains examples of pipelines in the `.github/workflows` directory.\n\nCheck out the guidelines for [Prisma migrations deployment][2], or for your preferred migration tool.\n\n## Docker Validation\n\nThe initialization script installs Docker and configures it to use the mounted EBS volume as data root.\n\nVerify that the volume has been mapped:\n\n```sh\nlsblk\nls /var/lib/docker/\nls /mnt/data\ndocker pull hello-world\ndocker system prune\n```\n\n## Local development\n\nStart bu running a MySQL instance:\n\n```sh\ndocker run -d \\\n    -e MYSQL_DATABASE=mysqldb \\\n    -e MYSQL_ROOT_PASSWORD=cxvxc2389vcxzv234r \\\n    -p 3306:3306 \\\n    --name mysql-prisma-local \\\n    mysql:8.0\n```\n\nSpecial privileges are required by Prisma to apply [shadow databases][1].\n\nEnter the application directory:\n\n```sh\ncd app\n```\n\nApply the migrations:\n\n\u003e Whenever you update your Prisma schema, you will have to update your database schema using either `prisma migrate dev` or `prisma db push`. This will keep your database \nschema in sync with your Prisma schema. The commands will also regenerate Prisma Client.\n\n```sh\n# This calls generate under the hood\nnpx prisma migrate dev --name init\n```\n\nRun the application locally:\n\n```sh\nnpm run dev\n```\n\nCheck if the schema and database connections are working:\n\n```sh\ncurl localhost:3000/prisma\n```\n\n### Docker image\n\nTo verify that the Docker image, \n\n```sh\ndocker compose up\n```\n\nAdd the `DATABASE_URL` environment variable:\n\n```SH\nexport DATABASE_URL='mysql://root:cxvxc2389vcxzv234r@localhost:3306/mysqldb'\n```\n\nDeploy the migration:\n\n```sh\nnpx prisma migrate deploy\n```\n\n[1]: https://www.prisma.io/docs/concepts/components/prisma-migrate/shadow-database\n[2]: https://www.prisma.io/docs/guides/deployment/deploy-database-changes-with-prisma-migrate\n[5]: https://docs.github.com/en/enterprise-cloud@latest/actions/hosting-your-own-runners/managing-self-hosted-runners/configuring-the-self-hosted-runner-application-as-a-service\n[6]: https://docs.aws.amazon.com/ebs/latest/userguide/ebs-using-volumes.html\n[7]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepomatti%2Faws-github-runner-migrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepomatti%2Faws-github-runner-migrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepomatti%2Faws-github-runner-migrations/lists"}