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