Skip to content

resolve exhaustive-deps lint #156

resolve exhaustive-deps lint

resolve exhaustive-deps lint #156

name: Build and Deploy
on:
push:
branches:
- "*"
permissions:
packages: write
jobs:
build_api_srv:
runs-on: ubuntu-latest
env:
MACONDO_DATA_PATH: ${{ github.workspace }}/data
TEST_DB_HOST: localhost
TEST_DB_PREFIX: liwords_test
DB_PORT: 5432
DB_USER: postgres
DB_PASSWORD: pass
DB_SSL_MODE: disable
DB_MIGRATIONS_PATH: file:///${{ github.workspace }}/db/migrations
REDIS_URL: redis://localhost:6379
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 3s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: pass
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v4
# - name: Clone macondo
# uses: actions/checkout@v4
# with:
# repository: domino14/macondo
# path: macondo
# - run: mv $GITHUB_WORKSPACE/macondo /opt/macondo
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ">=1.22"
- name: Build API
run: cd cmd/liwords-api && go build
- name: Test API
run: go test -race ./...
- name: Build Puzzle Generator
run: cd cmd/puzzlegen && go build
- name: Build Maintenance
run: cd cmd/maintenance && go build
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "liwords backend built successfully for branch {{GITHUB_REF_NAME}}."
deploy_api_docker:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
needs: build_api_srv
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: domino14
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Tag Docker Image
run: cd deploy && ./build-and-tag.sh
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_EMBEDS: '[ {
"fields": [
{ "name": "Repository", "value": "[${{github.event.repository.name}}](${{github.event.repository.clone_url}})", "inline": true },
{ "name": "Branch", "value": "[${{github.ref_name}}](https://github.com/${{github.repository}}/tree/${{github.ref_name}})", "inline": true },
{ "name": "Tag", "value": "ghcr.io/woogles-io/liwords-api:${{github.ref_name}}-gh${{github.run_number}}"}
],
"color":1127128
} ]'
uses: Ilshidur/action-discord@master
with:
args: ""
build_fe:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
check-latest: true
- name: Install Dependencies
run: cd liwords-ui && npm ci
- name: Test Frontend
run: cd liwords-ui && npm run test
- name: Build Frontend
run: cd liwords-ui && npm run build
- name: Persist Dist Directory
uses: actions/upload-artifact@v4
with:
path: liwords-ui/dist
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "liwords front-end built successfully for branch {{GITHUB_REF_NAME}}."
deploy_fe:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
needs: build_fe
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-2
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Dist Directory
uses: actions/download-artifact@v4
with:
path: /tmp/liwords-ui
- name: Calculate UI Hash
run: |
ls -al /tmp/liwords-ui/artifact
UI_HASH=$(find /tmp/liwords-ui/artifact -type f -exec md5sum {} \; | sort -k 2 | md5sum | head -c 32)
echo $UI_HASH
sed -i "s:unknown:${UI_HASH}:" /tmp/liwords-ui/artifact/config.js
echo "export UI_HASH=$UI_HASH" >> $GITHUB_ENV
- name: Install AWS CLI
run: |
sudo apt-get update
sudo apt-get install -y awscli
- name: Sync to S3 (Cache Everything)
run: |
cd /tmp/liwords-ui/artifact &&
aws s3 sync --cache-control 'max-age=3024000' \
--exclude index.html --exclude config.js --exclude '*.wasm' \
--metadata FEHash=${UI_HASH} \
. s3://woogles.io
- name: Sync to S3 (No Cache Except Wasm)
run: |
cd /tmp/liwords-ui/artifact &&
aws s3 sync --cache-control 'no-cache' --exclude '*.wasm' \
--metadata FEHash=${UI_HASH} \
. s3://woogles.io
- name: Cache Wasm File Separately
run: |
cd /tmp/liwords-ui/artifact &&
aws s3 sync --cache-control 'max-age=3024000' --exclude '*' --include '*.wasm' \
--metadata FEHash=${UI_HASH} \
--content-type 'application/wasm' . s3://woogles.io
- name: Update Frontend Hash
run: |
curl -X POST -H "Content-Type: application/json" \
-H "X-Api-Key: ${{ secrets.ADMIN_WOOGLES_API_KEY }}" \
https://woogles.io/api/config_service.ConfigService/SetFEHash \
-d "{\"hash\": \"$UI_HASH\"}"
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: "liwords front-end deployed successfully for branch {{GITHUB_REF_NAME}}."