mirror of
https://github.com/LukeHagar/website.git
synced 2025-12-06 04:22:07 +00:00
82 lines
3.9 KiB
YAML
82 lines
3.9 KiB
YAML
name: Production deployment
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
env:
|
|
TAG: ${{ github.event.release.tag_name }}
|
|
STACK_FILE: docker/production.yml
|
|
REPOSITORY: website
|
|
REGISTRY_USERNAME: christyjacob4
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout the repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ghcr.io/appwrite/website:${{ env.TAG }}
|
|
build-args: |
|
|
"PUBLIC_APPWRITE_ENDPOINT=${{ vars.PUBLIC_APPWRITE_ENDPOINT }}"
|
|
"PUBLIC_APPWRITE_DASHBOARD=${{ vars.PUBLIC_APPWRITE_DASHBOARD }}"
|
|
"PUBLIC_APPWRITE_PROJECT_ID=${{ vars.PUBLIC_APPWRITE_PROJECT_ID }}"
|
|
"PUBLIC_APPWRITE_DB_MAIN_ID=${{ vars.PUBLIC_APPWRITE_DB_MAIN_ID }}"
|
|
"PUBLIC_APPWRITE_COL_THREADS_ID=${{ vars.PUBLIC_APPWRITE_COL_THREADS_ID }}"
|
|
"PUBLIC_APPWRITE_COL_MESSAGES_ID=${{ vars.PUBLIC_APPWRITE_COL_MESSAGES_ID }}"
|
|
"PUBLIC_APPWRITE_FN_TLDR_ID=${{ vars.PUBLIC_APPWRITE_FN_TLDR_ID }}"
|
|
"PUBLIC_APPWRITE_PROJECT_INIT_ID=${{ vars.PUBLIC_APPWRITE_PROJECT_INIT_ID }}"
|
|
"PUBLIC_GROWTH_ENDPOINT=${{ vars.PUBLIC_GROWTH_ENDPOINT }}"
|
|
"PUBLIC_POSTHOG_API_KEY=${{ vars.PUBLIC_POSTHOG_API_KEY }}"
|
|
"APPWRITE_DB_INIT_ID=${{ secrets.APPWRITE_DB_INIT_ID }}"
|
|
"APPWRITE_COL_INIT_ID=${{ secrets.APPWRITE_COL_INIT_ID }}"
|
|
"APPWRITE_API_KEY_INIT=${{ secrets.APPWRITE_API_KEY_INIT }}"
|
|
"GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}"
|
|
"SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"
|
|
"SENTRY_RELEASE=${{ github.event.release.tag_name }}"
|
|
|
|
deploy:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Execute SSH commands
|
|
uses: appleboy/ssh-action@master
|
|
with:
|
|
host: ${{ secrets.PRD_SSH_HOST }}
|
|
username: ${{ secrets.PRD_SSH_USERNAME }}
|
|
key: ${{ secrets.PRD_SSH_KEY }}
|
|
script: |
|
|
url="https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/appwrite/${{ env.REPOSITORY }}.git"
|
|
if ! git clone "${url}" "${{ env.REPOSITORY }}" 2>/dev/null && [ -d "${{ env.REPOSITORY }}" ] ; then
|
|
echo "Clone failed because the folder ${{ env.REPOSITORY }} exists"
|
|
fi
|
|
|
|
cd ${{ env.REPOSITORY }}
|
|
git reset --hard HEAD
|
|
git remote set-url origin $url
|
|
git fetch origin
|
|
git checkout ${{ env.TAG }}
|
|
|
|
rm -f .env
|
|
echo "_APP_VERSION=${{ env.TAG }}" >> .env
|
|
echo "_APP_DOMAIN=${{ secrets.PRD_APP_DOMAIN }}" >> .env
|
|
echo "_APP_SYSTEM_SECURITY_EMAIL_ADDRESS=${{ secrets.APP_SYSTEM_SECURITY_EMAIL_ADDRESS }}" >> .env
|
|
echo "_APP_BETTER_STACK_INCIDENT_URL=${{ secrets.BETTER_STACK_INCIDENT_URL }}" >> .env
|
|
|
|
echo ${{ secrets.GH_REGISTRY_TOKEN }} | docker login ghcr.io --username ${{ env.REGISTRY_USERNAME }} --password-stdin
|
|
docker-compose -f ${{ env.STACK_FILE }} config
|
|
env $(cat .env | xargs) docker stack deploy --prune --resolve-image always --with-registry-auth -c ${{ env.STACK_FILE }} ${{ env.REPOSITORY }}
|