test cronjob time #28
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: rpgf6-staging-deploy-pipeline | |
on: | |
push: | |
branches: | |
- rf6-staging | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
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/generalmagicio/rpgf6-be:staging | |
deploy: | |
runs-on: ubuntu-latest | |
needs: publish | |
steps: | |
- name: SSH and Redeploy Production | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.RPGF6_STAGING_HOST }} | |
username: ${{ secrets.RPGF6_STAGING_USERNAME }} | |
key: ${{ secrets.RPGF6_STAGING_PRIVATE_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
cd pw-backend | |
git reset --hard HEAD~1 | |
git checkout rf6-staging | |
git pull origin rf6-staging | |
docker image prune -a --force | |
docker compose -f docker-compose-all.yml pull | |
## Update each backend service one by one | |
docker compose -f docker-compose-all.yml up -d --no-deps --scale pw-backend1=0 --scale pw-backend2=1 | |
docker compose -f docker-compose-all.yml up -d | |
# Check the health of pw-backend1 | |
if [ "$(docker inspect --format='{{json .State.Status}}' pw-backend1)" != "\"running\"" ]; then | |
echo "pw-backend1 is not running, stopping deployment" | |
exit 1 | |
fi | |
docker compose -f docker-compose-all.yml up -d --no-deps --scale pw-backend1=1 --scale pw-backend2=0 | |
docker compose -f docker-compose-all.yml up -d | |
# Check the health of pw-backend2 | |
if [ "$(docker inspect --format='{{json .State.Status}}' pw-backend2)" != "\"running\"" ]; then | |
echo "pw-backend2 is not running, stopping deployment" | |
exit 1 | |
fi |