name: Build and deploy website. on: push: # paths: # - "content/**" # - "static/**" # - "templates/**" branches: - "master" - "ci-testing" jobs: job1: name: Build static site. runs-on: catthehacker-ubuntu steps: - name: Get current date id: date run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')" - name: Set up docker buildx... uses: docker/setup-buildx-action@v3 - name: Login to gitea registry uses: docker/login-action@v3 with: registry: gitea.raer.me username: ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} password: ${{ secrets.PRODUCTION_REGISTRY_TOKEN }} - name: Checkout the git repo... uses: actions/checkout@v3 with: ref: master - name: Checkout the docker build branch... uses: actions/checkout@v3 with: ref: ci-testing path: docker - name: Install required system packages... run: | export DEBIAN_FRONTEND=noninteractive apt update apt upgrade -y apt install -y graphicsmagick p7zip-full - name: Use Node.js uses: actions/setup-node@v2 with: node-version: '14' - name: Install node dependencies run: npm ci - name: Lint JS code run: npm test - name: Build site run: npm run build - name: Copy dist to docker... run: npm cache clean --force;mv dist docker/build - name: Build and push docker image to gitea package store uses: docker/build-push-action@v5 with: context: docker/.docker/Dockerfile push: true platforms: linux/amd64 tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} - name: Create artifact... run: 7z a -mx=9 artifact.7z dist - name: Upload artifact... uses: actions/upload-artifact@v3 with: name: build_artifact path: artifact.7z retention-days: 7 # job2: # needs: job1 # name: Build new docker container with new site build... # runs-on: catthehacker-ubuntu # steps: # - # name: Install required system packages... # run: | # export DEBIAN_FRONTEND=noninteractive # apt update # apt upgrade -y # apt install -y p7zip-full # - # name: Download artifact... # uses: actions/download-artifact@v3 # with: # path: / # - # run: | # 7z x /build_artifact/artifact.7z /dist; ls /dist # # - # name: Checkout the docker build branch... # uses: actions/checkout@v3 # with: # ref: ci-testing # - # name: Set up docker buildx... # uses: docker/setup-buildx-action@v3 # - # name: Login to gitea registry # uses: docker/login-action@v3 # with: # registry: gitea.raer.me # username: ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} # password: ${{ secrets.PRODUCTION_REGISTRY_TOKEN }} # - # name: Build and push docker image to gitea package store # uses: docker/build-push-action@v5 # with: # context: .docker/Dockerfile # push: true # platforms: linux/amd64 # tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} job2: needs: job1 name: Connect to deployment host, update, and redeploy docs website. runs-on: ubuntu-latest steps: - name: Install required system packages... run: | export DEBIAN_FRONTEND=noninteractive apt update apt upgrade -y apt install -y iputils-ping - name: Configure SSH... env: SSH_USER: ${{ secrets.PRODUCTION_SSH_USER }} SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }} SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }} run: | mkdir -p ~/.ssh/ echo "$SSH_KEY" > ~/.ssh/staging.key chmod 600 ~/.ssh/staging.key cat >> ~/.ssh/config <