mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:20:47 +00:00
Automatically deploy from any branch, PR comments on deploy (#638)
## Description: - Automatically deploy from any branch - Add a PR comment on deployment  ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
This commit is contained in:
@@ -28,10 +28,11 @@ on:
|
||||
default: ""
|
||||
type: string
|
||||
|
||||
# Automatic deployment when pushing to main
|
||||
# Automatic deployment on push
|
||||
# See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
@@ -41,13 +42,16 @@ jobs:
|
||||
name: Deploy to ${{ inputs.target_subdomain && format('{0}.{1}', inputs.target_subdomain, inputs.target_domain) || inputs.target_domain || 'openfront.dev' }}
|
||||
runs-on: ubuntu-latest
|
||||
environment: ${{ inputs.target_subdomain && format('{0}.{1}', inputs.target_subdomain, inputs.target_domain) || inputs.target_domain || 'openfront.dev' }}
|
||||
|
||||
env:
|
||||
DOMAIN: ${{ inputs.target_domain || 'openfront.dev' }}
|
||||
SUBDOMAIN: ${{ github.event_name == 'push' && github.ref_name || inputs.target_subdomain || 'main' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Update deployment status
|
||||
env:
|
||||
FQDN: ${{ inputs.target_subdomain && format('{0}.{1}', inputs.target_subdomain, inputs.target_domain) || inputs.target_domain || 'openfront.dev' }}
|
||||
FQDN: ${{ env.SUBDOMAIN && format('{0}.{1}', env.SUBDOMAIN, env.DOMAIN) || env.DOMAIN || 'openfront.dev' }}
|
||||
run: |
|
||||
echo "FQDN=$FQDN" >> $GITHUB_ENV
|
||||
cat <<EOF >> $GITHUB_STEP_SUMMARY
|
||||
### In progress :ship:
|
||||
|
||||
@@ -79,14 +83,13 @@ jobs:
|
||||
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
||||
DOCKER_REPO: ${{ vars.DOCKERHUB_REPO }}
|
||||
DOCKER_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
DOMAIN: ${{ inputs.target_domain || 'openfront.dev' }}
|
||||
ENV: ${{ inputs.target_domain == 'openfront.io' && 'prod' || 'staging' }}
|
||||
HOST: ${{ github.event_name == 'workflow_dispatch' && inputs.target_host || 'staging' }}
|
||||
MON_PASSWORD: ${{ secrets.MON_PASSWORD }}
|
||||
MON_USERNAME: ${{ secrets.MON_USERNAME }}
|
||||
OTEL_ENDPOINT: ${{ secrets.OTEL_ENDPOINT }}
|
||||
OTEL_USERNAME: ${{ secrets.OTEL_USERNAME }}
|
||||
OTEL_PASSWORD: ${{ secrets.OTEL_PASSWORD }}
|
||||
OTEL_USERNAME: ${{ secrets.OTEL_USERNAME }}
|
||||
R2_ACCESS_KEY: ${{ secrets.R2_ACCESS_KEY }}
|
||||
R2_BUCKET: ${{ secrets.R2_BUCKET }}
|
||||
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
|
||||
@@ -94,7 +97,6 @@ jobs:
|
||||
SERVER_HOST_STAGING: ${{ secrets.SERVER_HOST_STAGING }}
|
||||
SERVER_HOST_US: ${{ secrets.SERVER_HOST_US }}
|
||||
SSH_KEY: ~/.ssh/id_rsa
|
||||
SUBDOMAIN: ${{ inputs.target_subdomain || 'main' }}
|
||||
VERSION_TAG: latest
|
||||
run: |
|
||||
echo "::group::deploy.sh"
|
||||
@@ -102,18 +104,29 @@ jobs:
|
||||
echo "::endgroup::"
|
||||
- name: Update deployment status ✅
|
||||
if: success()
|
||||
env:
|
||||
FQDN: ${{ inputs.target_subdomain && format('{0}.{1}', inputs.target_subdomain, inputs.target_domain) || inputs.target_domain || 'openfront.dev' }}
|
||||
run: |
|
||||
cat <<EOF >> $GITHUB_STEP_SUMMARY
|
||||
### Success! :rocket:
|
||||
|
||||
Deployed from $GITHUB_REF to $FQDN
|
||||
EOF
|
||||
|
||||
- name: Notify PR 🚀
|
||||
if: ${{ success() && github.event_name == 'push' }}
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
|
||||
echo "Checking for open PR from $GITHUB_HEAD_REF..."
|
||||
pr_url=$(gh pr list --head "$GITHUB_HEAD_REF" --state open --json url -q '.[0].url')
|
||||
if [ -z "$pr_url" ]; then
|
||||
echo "No open PR found for branch $GITHUB_HEAD_REF"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
gh pr comment "$pr_url" --body "🚀 Deployed ${GITHUB_SHA} to [$FQDN](https://$FQDN)."
|
||||
|
||||
- name: Update deployment status ❌
|
||||
if: failure()
|
||||
env:
|
||||
FQDN: ${{ inputs.target_subdomain && format('{0}.{1}', inputs.target_subdomain, inputs.target_domain) || inputs.target_domain || 'openfront.dev' }}
|
||||
run: |
|
||||
cat <<EOF >> $GITHUB_STEP_SUMMARY
|
||||
### Failure! :fire:
|
||||
|
||||
Reference in New Issue
Block a user