New CI just dropped

This commit is contained in:
2024-09-06 01:42:38 -07:00
parent 43952af0ec
commit fc0526e060

View File

@@ -3,7 +3,7 @@ on:
push: push:
branches: branches:
- "master" - "master"
- "production" - "gdb.lgbtqi.app-production"
jobs: jobs:
job1: job1:
@@ -16,22 +16,22 @@ jobs:
run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')" run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')"
- -
name: Set up docker buildx... name: Set up docker buildx...
uses: docker/setup-buildx-action@v3 uses: https://github.com/docker/setup-buildx-action@v3
- -
name: Login to gitea registry name: Login to gitea registry
uses: docker/login-action@v3 uses: https://github.com/docker/login-action@v3
with: with:
registry: gitea.raer.me registry: gitea.raer.me
username: ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.PRODUCTION_REGISTRY_TOKEN }} password: ${{ secrets.REGISTRY_TOKEN }}
- -
name: Checkout the git repo... name: Checkout the git repo...
uses: actions/checkout@v3 uses: https://github.com/actions/checkout@v3
with: with:
ref: master ref: master
- -
name: Checkout the docker build branch... name: Checkout the docker build branch...
uses: actions/checkout@v3 uses: https://github.com/actions/checkout@v3
with: with:
ref: production ref: production
path: docker path: docker
@@ -44,7 +44,7 @@ jobs:
apt install -y graphicsmagick p7zip-full apt install -y graphicsmagick p7zip-full
- -
name: Use Node.js name: Use Node.js
uses: actions/setup-node@v2 uses: https://github.com/actions/setup-node@v2
with: with:
node-version: '14' node-version: '14'
- -
@@ -61,12 +61,12 @@ jobs:
run: npm cache clean --force;cp -a dist docker/.docker/dist run: npm cache clean --force;cp -a dist docker/.docker/dist
- -
name: Use Node.js name: Use Node.js
uses: actions/setup-node@v2 uses: https://github.com/actions/setup-node@v2
with: with:
node-version: '20' node-version: '20'
- -
name: Build and push docker image to gitea package store name: Build and push docker image to gitea package store
uses: docker/build-push-action@v5 uses: https://github.com/docker/build-push-action@v5
with: with:
context: docker/.docker context: docker/.docker
push: true push: true
@@ -77,12 +77,11 @@ jobs:
run: 7z a -mx=9 artifact.7z dist run: 7z a -mx=9 artifact.7z dist
- -
name: Upload artifact... name: Upload artifact...
uses: actions/upload-artifact@v3 uses: https://github.com/actions/upload-artifact@v3
with: with:
name: build_artifact name: build_artifact
path: artifact.7z path: artifact.7z
retention-days: 7 retention-days: 7
job2: job2:
needs: job1 needs: job1
name: Connect to deployment host, update, and redeploy docs website. name: Connect to deployment host, update, and redeploy docs website.
@@ -98,9 +97,9 @@ jobs:
- -
name: Configure SSH... name: Configure SSH...
env: env:
SSH_USER: ${{ secrets.PRODUCTION_SSH_USER }} SSH_USER: ${{ secrets.DEPLOYMENT_USER }}
SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }} SSH_KEY: ${{ secrets.DEPLOYMENT_KEY }}
SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }} SSH_HOST: ${{ secrets.DEPLOYMENT_HOST }}
run: | run: |
mkdir -p ~/.ssh/ mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/staging.key echo "$SSH_KEY" > ~/.ssh/staging.key
@@ -114,20 +113,16 @@ jobs:
END END
cat ~/.ssh/config cat ~/.ssh/config
- -
name: Test SSH Host... name: Ping ssh host...
env: env:
SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }} SSH_HOST: ${{ secrets.DEPLOYMENT_HOST }}
run: | run: |
ping -c 3 $SSH_HOST ping -c 3 $SSH_HOST
ssh staging 'ls'
- -
name: Pull new image and redeploy... name: Run deployment script...
run: | env:
ssh staging '\ SSH_HOST: ${{ secrets.DEPLOYMENT_HOST }}
echo "${{ secrets.PRODUCTION_REGISTRY_TOKEN }}" | docker login --password-stdin --username ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} gitea.raer.me; \ run:
docker stop gdb.lgbtqi.app; \ ssh staging
docker rm gdb.lgbtqi.app; \
docker pull gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }}; \
docker run -d --name gdb.lgbtqi.app -p ${{ secrets.PRODUCTION_DEPLOYMENT_HOST }}:4100:80 gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }}; \
docker logout gitea.raer.me;'