Deploy Prod configuration #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Prod configuration | |
on: | |
workflow_run: | |
workflows: ["Create and publish a Docker image"] | |
types: [completed] | |
branches: | |
- 'main' | |
- 'v*' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to SSH target | |
uses: appleboy/ssh-action@v1.1.0 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.ACCESS_KEY }} | |
script: | | |
temp_env_file=$(mktemp) | |
echo """${{secrets.COMPOSE_ENV}}""" >> $temp_env_file | |
echo "ENV_PATH=$temp_env_file" >> $temp_env_file | |
if [ ! -d socialpredict-deploy ] | |
then | |
git clone ${{ github.server_url }}/${{ github.repository }} socialpredict-deploy | |
cd socialpredict-deploy | |
else | |
cd socialpredict-deploy | |
git fetch origin | |
fi | |
template="./frontend/src/config.js.template" | |
file="./frontend/src/config.js" | |
export API_DOMAIN="'https://${DOMAIN}'" | |
envsubst < $template > $file | |
git checkout ${{ github.sha }} | |
echo "${{ secrets.DOCKER_TOKEN }}" | docker login ghcr.io -u j4qfrost --password-stdin | |
docker compose -f ./scripts/docker-compose-prod.yaml \ | |
--env-file $temp_env_file \ | |
up -d | |
lighthouse: | |
needs: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Audit URLs using Lighthouse | |
uses: treosh/lighthouse-ci-action@v12 | |
with: | |
urls: | | |
https://openprediction.xyz/ | |
budgetPath: ./scripts/lighthouse # test performance budgets | |
uploadArtifacts: true # save results as an action artifacts | |
temporaryPublicStorage: true # upload lighthouse report to the temporary storage |