Skip to content

Commit

Permalink
Add missing env vars and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ohrie committed Oct 29, 2024
1 parent dd23d3c commit 57b4055
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 15 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/deploy-app-ionos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ on:
NEXT_PUBLIC_APP_ENV:
required: true
type: string
NEXT_PUBLIC_OSM_API_URL:
APP_ORIGIN:
required: true
type: string
APP_URL:
ASSETS_BUCKET_HOST:
required: true
type: string
CONFIG_CHANGED:
type: boolean
ASSETS_BUCKET_PATH:
required: true
type: boolean

Expand Down Expand Up @@ -68,7 +68,6 @@ jobs:
build-args: |
NEXT_PUBLIC_APP_ENV=${{ inputs.NEXT_PUBLIC_APP_ENV }}
NEXT_PUBLIC_APP_ORIGIN=${{ inputs.NEXT_PUBLIC_APP_ORIGIN }}
NEXT_PUBLIC_OSM_API_URL=${{ inputs.NEXT_PUBLIC_OSM_API_URL }}
- name: Push nginx image
run: |
Expand All @@ -88,9 +87,8 @@ jobs:
public.ecr.aws/n0p8j4k5/trassenscout/nginx:${{ github.sha }}
public.ecr.aws/n0p8j4k5/trassenscout/nginx:${{ inputs.ENVIRONMENT }}-latest
build-args: |
NEXT_PUBLIC_APP_ENV=${{ inputs.NEXT_PUBLIC_APP_ENV }}
NEXT_PUBLIC_APP_ORIGIN=${{ inputs.NEXT_PUBLIC_APP_ORIGIN }}
NEXT_PUBLIC_OSM_API_URL=${{ inputs.NEXT_PUBLIC_OSM_API_URL }}
ASSETS_BUCKET_HOST=${{ inputs.ASSETS_BUCKET_HOST }}
ASSETS_BUCKET_PATH=${{ inputs.ASSETS_BUCKET_PATH }}
- name: Push image
run: |
Expand All @@ -102,7 +100,7 @@ jobs:
if: ${{ needs.diff_app.outputs.changes == 'true' || inputs.CONFIG_CHANGED && always() }}
environment:
name: ${{ inputs.ENVIRONMENT }}
url: https://${{ inputs.APP_URL }}
url: ${{ inputs.APP_ORIGIN }}
steps:
- name: Stop & Start container on Server
uses: appleboy/ssh-action@master
Expand All @@ -111,7 +109,7 @@ jobs:
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
script: |
cd /srv
cd /srv/trassenscout-${{ inputs.ENVIRONMENT }}
echo "Pulling latest 'app' image"
docker compose pull app
echo "Restarting 'app' container"
Expand Down
26 changes: 21 additions & 5 deletions .github/workflows/deploy-app-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,45 @@ on:
branches:
- migration-ionos
jobs:
setup_env:
uses: ./.github/workflows/setup-env.yml
with:
ENVIRONMENT: staging
TILES_URL: staging-tiles.radverkehrsatlas.de
CACHELESS_URL: staging-cacheless.radverkehrsatlas.de
NEXT_PUBLIC_APP_ORIGIN: https://staging.radverkehrsatlas.de
NEXT_PUBLIC_APP_ENV: staging
NEXT_PUBLIC_OSM_API_URL: https://master.apis.dev.openstreetmap.org/api/0.6
APP_URL: staging.radverkehrsatlas.de
secrets: inherit
restart_services:
uses: ./.github/workflows/restart-services.yml
needs: setup_env
with:
ENVIRONMENT: staging
secrets: inherit
call-deploy-app:
needs: restart_services
uses: ./.github/workflows/deploy-app-ionos.yml
with:
ENVIRONMENT: staging
APP_ORIGIN: http://staging.trassenscout.de
NEXT_PUBLIC_APP_ORIGIN: http://staging.trassenscout.de
NEXT_PUBLIC_APP_ENV: staging
SERVICE_NAME: trassenscout-staging
S3_UPLOAD_BUCKET: trassenscout
S3_UPLOAD_REGION: eu-central-1
S3_UPLOAD_ROOTFOLDER: upload-staging
ENVIRONMENT: staging
URL: staging.trassenscout.de
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
SESSION_SECRET_KEY: ${{ secrets.SESSION_SECRET_KEY}}
NGINX_HTPASSWD: ${{ secrets.NGINX_HTPASSWD }}
MAILJET_APIKEY_PUBLIC: ${{ secrets.MAILJET_APIKEY_PUBLIC }}
MAILJET_APIKEY_PRIVATE: ${{ secrets.MAILJET_APIKEY_PRIVATE }}
NGINX_HTPASSWD: ${{ secrets.NGINX_HTPASSWD }}
S3_UPLOAD_KEY: ${{ secrets.S3_UPLOAD_KEY }}
FELT_TOKEN: ${{ secrets.FELT_TOKEN }}
S3_UPLOAD_SECRET: ${{ secrets.S3_UPLOAD_SECRET }}
FELT_TOKEN: ${{ secrets.FELT_TOKEN }}
ASSETS_BUCKET_HOST: ${{ secrets.ASSETS_BUCKET_HOST }}
ASSETS_BUCKET_PATH: ${{ secrets.ASSETS_BUCKET_PATH }}
ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }}
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/restart-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Restart Services

on:
workflow_call:
inputs:
ENVIRONMENT:
type: string
required: true
outputs:
CHANGES:
description: "Whether `configs/` or the `docker-compose` files have changed since the last successfull workflow run."
value: ${{ jobs.check_config_changes.outputs.CHANGES }}

jobs:
check_config_changes:
uses: ./.github/workflows/diff-last-run.yml
with:
CHECK_DIFF_LOCATIONS: docker-compose* .env.example
restart_services:
needs: check_config_changes
if: ${{ needs.check_config_changes.outputs.changes == 'true' }}
runs-on: ubuntu-latest
environment:
name: ${{ inputs.ENVIRONMENT }}
steps:
- name: Restart containers
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
script: |
cd /srv/trassenscout-${{ inputs.ENVIRONMENT }}
echo "Restarting containers: tiles, db, traefik and proxy"
docker compose pull
docker compose -f docker-compose.yml up db traefik app nginx -d
docker image prune -fa
1 change: 1 addition & 0 deletions .github/workflows/setup-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ jobs:
-e "s|^S3_UPLOAD_KEY=.*$|S3_UPLOAD_KEY='${{ secrets.S3_UPLOAD_KEY }}'|" \
-e "s|^S3_UPLOAD_SECRET=.*$|S3_UPLOAD_SECRET='${{ secrets.S3_UPLOAD_SECRET }}'|" \
-e "s|^S3_UPLOAD_ROOTFOLDER=.*$|S3_UPLOAD_ROOTFOLDER='${{ vars.S3_UPLOAD_ROOTFOLDER }}'|" \
-e "s|^APP_URL=.*$|APP_URL='${{ vars.APP_URL }}'|" \
-e "s|^TS_API_KEY=.*$|TS_API_KEY='${{ secrets.TS_API_KEY }}'|" \
.env

0 comments on commit 57b4055

Please sign in to comment.