From 9ec2d287a2745a54353511e1620e6acc05f5334b Mon Sep 17 00:00:00 2001 From: Alexander Heimbuch Date: Thu, 3 Oct 2024 16:02:33 +0200 Subject: [PATCH] ci: add production release --- .github/workflows/production.yml | 40 ++++++++++++++++++++++++++++++++ .github/workflows/staging.yml | 1 - devbox.d/caddy/Caddyfile | 2 +- devbox.json | 15 ++++++++++-- process-compose.yml | 2 +- 5 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/production.yml diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml new file mode 100644 index 0000000..5156494 --- /dev/null +++ b/.github/workflows/production.yml @@ -0,0 +1,40 @@ +name: Production +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Prepare Remote + uses: appleboy/ssh-action@v1.0.3 + with: + host: services.podlove.org + username: root + key: ${{ secrets.PRODUCTION_SSH_KEY }} + script: | + mkdir -p app + cd app + git ls-remote git@github.com:podlove/publisher-services.git -q || git clone git@github.com:podlove/publisher-services.git . + git reset --hard ${{ github.sha }} + + - name: Deploy to production environment + uses: appleboy/ssh-action@v1.0.3 + env: + SHA: ${{ github.sha }} + VITE_BUILD: ${{ github.sha }} + with: + host: services.podlove.org + username: root + key: ${{ secrets.PRODUCTION_SSH_KEY }} + envs: SHA,VITE_BUILD + script: | + cd app + git fetch + git reset --hard $SHA + devbox install + devbox services down + devbox run bootstrap + devbox run build + devbox services up --background diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index e988946..d5e7775 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -15,7 +15,6 @@ jobs: username: root key: ${{ secrets.STAGING_SSH_KEY }} script: | - which devbox || curl -fsSL https://get.jetify.com/devbox | bash mkdir -p app cd app git ls-remote git@github.com:podlove/publisher-next.git -q || git clone -–depth=1 git@github.com:podlove/publisher-next.git . diff --git a/devbox.d/caddy/Caddyfile b/devbox.d/caddy/Caddyfile index 51d2fe1..7dbb753 100644 --- a/devbox.d/caddy/Caddyfile +++ b/devbox.d/caddy/Caddyfile @@ -1,4 +1,4 @@ -publisher-services.podlove.dev { +publisher-services.podlove.dev, services.podlove.org { handle /api/* { reverse_proxy localhost:4005 } diff --git a/devbox.json b/devbox.json index 0b48c1f..9ef6603 100644 --- a/devbox.json +++ b/devbox.json @@ -17,13 +17,24 @@ "mix local.rebar --force", "mix deps.get" ], - "bootstrap": ["devbox run bootstrap:client", "devbox run bootstrap:server", "devbox run e2e:bootstrap"], + "bootstrap": [ + "devbox run bootstrap:client", + "devbox run bootstrap:server", + "devbox run e2e:bootstrap" + ], "test": ["devbox run test:server"], "test:server": ["cd server", "mix test"], "server": ["cd server", "mix run --no-halt"], "client": ["cd client", "pnpm run dev"], + "build:server": [ + "cd server", + "mix local.hex --force", + "mix local.rebar --force", + "mix deps.get --only prod", + "MIX_ENV=prod mix release" + ], "build:client": ["cd client", "pnpm build"], - "build": ["devbox run build:client"], + "build": ["devbox run build:server", "devbox run build:client"], "e2e:bootstrap": ["cd e2e", "pnpm install"], "e2e": ["cd e2e", "pnpm run dev"], "e2e:environment": ["docker compose --file e2e/docker-compose.yml up"] diff --git a/process-compose.yml b/process-compose.yml index 69a3aa9..cb4359f 100644 --- a/process-compose.yml +++ b/process-compose.yml @@ -2,7 +2,7 @@ version: "0.5" processes: server: - command: mix run --no-halt + command: server/_build/prod/rel/publisher/bin/publisher start working_dir: server environment: - "PORT=4005"