Skip to content

Deployment

Deployment #115

Workflow file for this run

---
name: Deployment
on:
workflow_dispatch:
inputs:
environment:
description: "Deploy target environment"
type: choice
options:
- stage
- prod
required: true
jobs:
deploy:
name: Deploy
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache images
uses: ScribeMD/[email protected]
with:
key: |
docker-${{ runner.os }}-${{ hashFiles(
'docker-compose*.yml',
'client/Dockerfile',
'client-e2e/Dockerfile',
'client-e2e/images/Dockerfile.*'
) }}
- name: Prepare environment
run: |
touch ./client/.env
if [ "${{ inputs.environment }}" = "prod" ]; then
echo "MAILBOX_URL=wss://mailbox.winden.app/v1" >> ./client/.env
echo "RELAY_URL=wss://relay.winden.app/" >> ./client/.env
else
echo "MAILBOX_URL=wss://mailbox.stage.winden.app/v1" >> ./client/.env
echo "RELAY_URL=wss://relay.stage.winden.app/" >> ./client/.env
fi
cat <<EOF >> ./client/.env
SFTP_HOSTNAME=${{ secrets.SFTP_HOSTNAME }}
SFTP_USERNAME=${{ secrets.SFTP_USERNAME }}
SFTP_IDENTITY="${{ secrets.SFTP_IDENTITY }}"
NODE_ENV=development
ENVIRONMENT=${{ inputs.environment }}
EOF
touch ./client-e2e/.env
- name: Fix group membership
run: |
# Add the existing `runner` group to avoid the `docker` one
sudo adduser runner runner
echo "_GID=$(grep -E "^runner:" /etc/group | cut -d: -f3)" >> $GITHUB_ENV
- name: Build image
run: |
repository=${{ github.repository }}
# Verify the cache
docker images --quiet ${repository##*/}-client:latest | grep -v "^$" && \
CLIENT=0 || CLIENT=1
# Build image if client is missing
test $CLIENT -eq 0 || \
docker compose --progress plain build --build-arg uid=$(id -u) --build-arg gid=${_GID} client
- name: Prepare containers
run: |
docker compose run --rm --no-deps -e CI=true client npm clean-install
- name: Deploy package
run: docker compose run --no-deps client npm run deploy