I have a self hosted GitHub Actions running in ECS and it has been working wonders, until I have to deal with service discovery.
The below is the workflow file
name: Checks before merging for core-service server
on:
push:
paths:
- 'tons/of/paths/**'
jobs:
build:
runs-on: [self-hosted, linux, x64, nomad]
#set a timeout just in case the tests hang
timeout-minutes: 5
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: test-db
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpassword
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.16
uses: actions/setup-node@v1
with:
node-version: 14.16
- name: Install dependencies
run: npm ci
working-directory: some-dependency/location
- name: Check if build is passing
run: npm run build
working-directory: more-dependency/more-places
- name: Run tests
run: npm run test
env:
DATABASE_URL: mysql://user:password@127.0.0.1:${{ job.services.mysql.ports[3306] }}/test-db
working-directory: core-service/server
The below is the error I'm getting
Using existing mysql database from: DATABASE_URL
Error: connect ECONNREFUSED 127.0.0.1:32777
Any comments will be appreciated. Have a nice day~