Skip to content

Fix services paths

Fix services paths #12

Workflow file for this run

name: princetonpy.org deployment
#on:
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
on:
push:
branches: ['release']
env:
REGISTRY: ghcr.io
jobs:
build-and-push-image:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- dockerfile: ./app/Dockerfile.prod
service: web
- dockerfile: ./app/Dockerfile-cron.prod
service: cron
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry using the account and password
# that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags
# and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be
# referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.service }}
# This step uses the `docker/build-push-action` action to build the image, based on your
# repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified
# path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of
# the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: ./app
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
copy-to-server:
needs: [build-and-push-image]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run a one-line script
run: echo Hello from Octo Organization
- name: rsync deployment
# You may pin to the exact commit or the version.
# uses: Burnett01/rsync-deployments@45d84ad5f6c174f3e0ffc50e9060a9666d09c16e
uses: Burnett01/[email protected]
with:
switches: -avzr --delete
# path: src/
# remote_path is the path under which "path" is checked out
# default is repo root - top-level files/dirs
remote_path: ${{ secrets.DEPLOY_PATH }}
remote_host: ${{ secrets.DEPLOY_HOST }}
remote_port: ${{ secrets.DEPLOY_PORT }}
remote_user: ${{ secrets.DEPLOY_USER }}
remote_key: ${{ secrets.CI_PRIVATE_KEY }}
restart-services:
needs: [copy-to-server]
runs-on: ubuntu-latest
steps:
- name: Execute SSH commmands on remote server
uses: JimCronqvist/action-ssh@master
env:
NAME: "Root"
with:
hosts: '[email protected]'
privateKey: ${{ secrets.CI_PRIVATE_KEY }}
debug: false
command: |
/usr/bin/cp /home/princeton/config/.env.* /home/princeton/deployed/
pull-image.sh
sudo /usr/bin/systemctl restart princetonpy-cron.service
sudo /usr/bin/systemctl restart princetonpy-web.service