refactor: accept that it's shitty #247
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test, Build, Deploy | |
on: | |
push: | |
paths-ignore: | |
- "*.md" | |
env: | |
DOCKER_REGISTRY: ghcr.io | |
DOCKER_USERNAME: ${{ github.actor }} | |
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
DOCKER_REGISTRY_URL: ghcr.io/${{ github.actor }} | |
DOCKER_IMAGE_VERSION: ${{ github.sha }} | |
BUILD_VERSION: ${{ github.sha }} | |
jobs: | |
conventions: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/workflows/composites/install_node_things/ | |
- run: pnpm lint | |
- run: pnpm format | |
test-unit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/workflows/composites/install_node_things/ | |
- run: pnpm test | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Log in with Docker | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ env.DOCKER_USERNAME }} | |
password: ${{ env.DOCKER_PASSWORD }} | |
- name: Build docker images | |
run: cd docker && ./dockerctl.sh prod build | |
- name: Push docker images | |
run: cd docker && ./dockerctl.sh prod push | |
test-e2e: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install node dependencies | |
uses: ./.github/workflows/composites/install_node_things/ | |
- name: Install playwright dependencies | |
run: pnpm dlx playwright install --with-deps | |
- name: Start application | |
run: cd ./docker && ./dockerctl.sh test up --no-build -d | |
- name: Run end-to-end tests | |
run: pnpm -F @mp/e2e start | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright | |
path: ./apps/e2e/.playwright/ | |
include-hidden-files: true | |
deploy: | |
needs: [conventions, build, test-unit, test-e2e] | |
if: github.ref_name == 'main' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Upload docker runtime dependencies | |
uses: burnett01/rsync-deployments@7.0.1 | |
with: | |
switches: -avz --delete | |
path: docker/ | |
remote_path: ~/docker | |
remote_host: ${{ vars.DEPLOY_SSH_HOST }} | |
remote_user: ${{ vars.DEPLOY_SSH_USERNAME }} | |
remote_key: ${{ secrets.DEPLOY_SSH_KEY }} | |
- name: Deploy via SSH action | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ vars.DEPLOY_SSH_HOST }} | |
username: ${{ vars.DEPLOY_SSH_USERNAME }} | |
key: ${{ secrets.DEPLOY_SSH_KEY }} | |
script_stop: true | |
script: | | |
cd ~/docker | |
# Set production host env vars | |
echo "DOCKER_REGISTRY_URL=\"${{ env.DOCKER_REGISTRY_URL }}\"" > .env | |
echo "DOCKER_IMAGE_VERSION=\"${{ env.DOCKER_IMAGE_VERSION }}\"" >> .env | |
echo "MP_SERVER_BUILD_VERSION=\"${{ env.BUILD_VERSION }}\"" >> .env | |
echo "MP_CLIENT_BUILD_VERSION=\"${{ env.BUILD_VERSION }}\"" >> .env | |
echo "MP_DOMAIN=\"${{ vars.MP_DOMAIN }}\"" >> .env | |
echo "KC_SMTP_HOST=\"${{ vars.KC_SMTP_HOST }}\"" >> .env | |
echo "KC_SMTP_PORT=\"${{ vars.KC_SMTP_PORT }}\"" >> .env | |
echo "KC_SMTP_USER=\"${{ vars.KC_SMTP_USER }}\"" >> .env | |
echo "KC_SMTP_PASSWORD=\"${{ secrets.KC_SMTP_PASSWORD }}\"" >> .env | |
echo ${{ env.DOCKER_PASSWORD }} | docker login ${{ env.DOCKER_REGISTRY }} -u ${{ env.DOCKER_USERNAME }} --password-stdin | |
./dockerctl.sh prod pull | |
./dockerctl.sh prod down | |
./dockerctl.sh prod up -d --remove-orphans --no-build | |
docker image prune |