Deploy to AUR on tag #80
Workflow file for this run
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: Release & deploy server container (tag) | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
name: Build container | |
strategy: | |
matrix: | |
container: [server, nginx] | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Get version | |
id: version | |
if: matrix.container == 'server' | |
uses: ./.github/actions/version | |
- | |
name: Set variables | |
shell: bash | |
if: matrix.container == 'server' | |
run: | | |
DATE=$(date +%Y%m%d) | |
YEAR=$(date +%Y) | |
# Only build on amd64 around the event (faster) | |
LABOR_DAY=$(date -d "${YEAR}-09-01 +$(( (8 - $(date -d "${YEAR}-09-01" +%u) ) % 7 )) days" +%Y-%m-%d) | |
BEFORE_DATE=$(date -d "$LABOR_DAY -21 days" +%Y%m%d) | |
AFTER_DATE=$(date -d "$LABOR_DAY +3 days" +%Y%m%d) | |
if [ "$DATE" -ge "$BEFORE_DATE" -a "$DATE" -le "$AFTER_DATE" ]; then | |
echo 'Close to Labor Day! Building for linux/amd64 only for performance reasons.' | |
echo 'PLATFORMS=linux/amd64' >> "$GITHUB_ENV" | |
else | |
echo 'PLATFORMS=linux/amd64,linux/arm64' >> "$GITHUB_ENV" | |
fi | |
- | |
name: Build container | |
uses: ./.github/actions/docker-build-push | |
if: matrix.container == 'server' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
container: server | |
tag: ${{ github.ref_name }} | |
no-cache: true | |
platforms: ${{ env.PLATFORMS }} | |
build-args: | | |
TOMATO_VERSION=${{ steps.version.outputs.version }} | |
- | |
name: Build container (nginx) | |
uses: ./.github/actions/docker-build-push | |
if: matrix.container == 'nginx' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
container: nginx | |
context: server/nginx | |
no-cache: true | |
tag: ${{ github.ref_name }} | |
deploy: | |
runs-on: ubuntu-22.04 | |
name: Deploy | |
needs: [build] | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Deploy containers | |
uses: appleboy/ssh-action@master | |
env: | |
TOMATO_TAG: ${{ github.ref_name }} | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
port: ${{ secrets.SSH_PORT }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
fingerprint: ${{ secrets.SSH_FINGERPRINT }} | |
envs: TOMATO_TAG | |
script: ${{ secrets.DEPLOY_PROD_SCRIPT_PATH }} |