From e3601faf8e98ac39be1aa746c9e20b837d09a037 Mon Sep 17 00:00:00 2001 From: SayaAndy Date: Mon, 4 May 2026 15:26:43 +0700 Subject: feat: integrate general use favicon.ico for search engines ci: use ansible dev tools to speed up deploy step --- .github/workflows/build-and-deploy-prod.yml | 26 ++++++++++++++++++++++-- .github/workflows/build-and-deploy-stage.yml | 30 ++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 10 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build-and-deploy-prod.yml b/.github/workflows/build-and-deploy-prod.yml index 97afdf7..ded8c93 100644 --- a/.github/workflows/build-and-deploy-prod.yml +++ b/.github/workflows/build-and-deploy-prod.yml @@ -50,10 +50,16 @@ jobs: runs-on: ubuntu-latest environment: Production needs: [build-and-push] + container: + image: ghcr.io/ansible/community-ansible-dev-tools:v26.4.6 + options: --user root steps: - name: Checkout uses: actions/checkout@v6 + - name: Install community.docker collection + run: ansible-galaxy collection install community.docker + - name: Set up SSH connection for uz.saya.casa run: | mkdir -p ~/.ssh @@ -77,7 +83,23 @@ jobs: - name: Run Ansible playbook env: - ANSIBLE_HOST_KEY_CHECKING: False + ANSIBLE_HOST_KEY_CHECKING: "False" working-directory: ./deploy run: | - ansible-playbook -i inventory.yml -l prod playbook.yml --private-key ~/.ssh/id_ed25519 -u svc_github -e saya_today_web_auth_salt="${{ secrets.AUTH_SALT }}" -e saya_today_web_s3_access_key_id="${{ secrets.S3_ACCESS_KEY_ID }}" -e saya_today_web_s3_secret_access_key="${{ secrets.S3_SECRET_ACCESS_KEY }}" -e saya_today_web_environment=prod -e saya_today_web_tag=${{ github.ref_name }} -e saya_today_web_mail_salt="${{ secrets.MAIL_SALT }}" -e saya_today_web_mail_host="${{ secrets.MAIL_HOST }}" -e saya_today_web_mail_address="${{ secrets.MAIL_ADDRESS }}" -e saya_today_web_mail_username="${{ secrets.MAIL_USERNAME }}" -e saya_today_web_mail_password="${{ secrets.MAIL_PASSWORD }}" -e saya_today_google_site_verification="${{ secrets.GOOGLE_SITE_VERIFICATION }}" -e saya_today_yandex_verification="${{ secrets.YANDEX_VERIFICATION }}" + ansible-playbook \ + -i inventory.yml \ + -l prod playbook.yml \ + --private-key ~/.ssh/id_ed25519 \ + -u svc_github \ + -e saya_today_web_auth_salt="${{ secrets.AUTH_SALT }}" \ + -e saya_today_web_s3_access_key_id="${{ secrets.S3_ACCESS_KEY_ID }}" \ + -e saya_today_web_s3_secret_access_key="${{ secrets.S3_SECRET_ACCESS_KEY }}" \ + -e saya_today_web_environment=prod \ + -e saya_today_web_tag=${{ github.ref_name }} \ + -e saya_today_web_mail_salt="${{ secrets.MAIL_SALT }}" \ + -e saya_today_web_mail_host="${{ secrets.MAIL_HOST }}" \ + -e saya_today_web_mail_address="${{ secrets.MAIL_ADDRESS }}" \ + -e saya_today_web_mail_username="${{ secrets.MAIL_USERNAME }}" \ + -e saya_today_web_mail_password="${{ secrets.MAIL_PASSWORD }}" \ + -e saya_today_google_site_verification="${{ secrets.GOOGLE_SITE_VERIFICATION }}" \ + -e saya_today_yandex_verification="${{ secrets.YANDEX_VERIFICATION }}" diff --git a/.github/workflows/build-and-deploy-stage.yml b/.github/workflows/build-and-deploy-stage.yml index ffee091..93a2627 100644 --- a/.github/workflows/build-and-deploy-stage.yml +++ b/.github/workflows/build-and-deploy-stage.yml @@ -52,10 +52,16 @@ jobs: runs-on: ubuntu-latest environment: Stage needs: [build-and-push] + container: + image: ghcr.io/ansible/community-ansible-dev-tools:v26.4.6 + options: --user root steps: - name: Checkout uses: actions/checkout@v6 + - name: Install community.docker collection + run: ansible-galaxy collection install community.docker + - name: Set up SSH connection for uz.saya.casa run: | mkdir -p ~/.ssh @@ -71,19 +77,27 @@ jobs: run: | ssh -o ConnectTimeout=10 -i ~/.ssh/id_ed25519 svc_github@uz.saya.casa "echo 'SSH connection successful'" - - name: Install Ansible - shell: bash - run: | - sudo apt update - sudo apt install -y ansible - - name: Set github short sha id: ghss_vars run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Run Ansible playbook env: - ANSIBLE_HOST_KEY_CHECKING: False + ANSIBLE_HOST_KEY_CHECKING: "False" working-directory: ./deploy run: | - ansible-playbook -i inventory.yml -l stage playbook.yml --private-key ~/.ssh/id_ed25519 -u svc_github -e saya_today_web_auth_salt="${{ secrets.AUTH_SALT }}" -e saya_today_web_s3_access_key_id="${{ secrets.S3_ACCESS_KEY_ID }}" -e saya_today_web_s3_secret_access_key="${{ secrets.S3_SECRET_ACCESS_KEY }}" -e saya_today_web_environment=stage -e saya_today_web_tag=commit-${{ steps.ghss_vars.outputs.sha_short }} -e saya_today_web_mail_salt="${{ secrets.MAIL_SALT }}" -e saya_today_web_mail_host="${{ secrets.MAIL_HOST }}" -e saya_today_web_mail_address="${{ secrets.MAIL_ADDRESS }}" -e saya_today_web_mail_username="${{ secrets.MAIL_USERNAME }}" -e saya_today_web_mail_password="${{ secrets.MAIL_PASSWORD }}" + ansible-playbook \ + -i inventory.yml \ + -l stage playbook.yml \ + --private-key ~/.ssh/id_ed25519 \ + -u svc_github \ + -e saya_today_web_auth_salt="${{ secrets.AUTH_SALT }}" \ + -e saya_today_web_s3_access_key_id="${{ secrets.S3_ACCESS_KEY_ID }}" \ + -e saya_today_web_s3_secret_access_key="${{ secrets.S3_SECRET_ACCESS_KEY }}" \ + -e saya_today_web_environment=stage \ + -e saya_today_web_tag=commit-${{ steps.ghss_vars.outputs.sha_short }} \ + -e saya_today_web_mail_salt="${{ secrets.MAIL_SALT }}" \ + -e saya_today_web_mail_host="${{ secrets.MAIL_HOST }}" \ + -e saya_today_web_mail_address="${{ secrets.MAIL_ADDRESS }}" \ + -e saya_today_web_mail_username="${{ secrets.MAIL_USERNAME }}" \ + -e saya_today_web_mail_password="${{ secrets.MAIL_PASSWORD }}" -- cgit v1.3.1+13 From 7b1aca39816f4b82ddf9c4ced83275d56e1b8780 Mon Sep 17 00:00:00 2001 From: SayaAndy Date: Mon, 4 May 2026 15:38:03 +0700 Subject: fix: no strict host key checking in ci --- .github/workflows/build-and-deploy-prod.yml | 2 +- .github/workflows/build-and-deploy-stage.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build-and-deploy-prod.yml b/.github/workflows/build-and-deploy-prod.yml index ded8c93..4689e28 100644 --- a/.github/workflows/build-and-deploy-prod.yml +++ b/.github/workflows/build-and-deploy-prod.yml @@ -73,7 +73,7 @@ jobs: - name: Test SSH connection run: | - ssh -o ConnectTimeout=10 -i ~/.ssh/id_ed25519 svc_github@uz.saya.casa "echo 'SSH connection successful'" + ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/.ssh/id_ed25519 svc_github@uz.saya.casa "echo 'SSH connection successful'" - name: Install Ansible shell: bash diff --git a/.github/workflows/build-and-deploy-stage.yml b/.github/workflows/build-and-deploy-stage.yml index 93a2627..f81212a 100644 --- a/.github/workflows/build-and-deploy-stage.yml +++ b/.github/workflows/build-and-deploy-stage.yml @@ -75,7 +75,7 @@ jobs: - name: Test SSH connection run: | - ssh -o ConnectTimeout=10 -i ~/.ssh/id_ed25519 svc_github@uz.saya.casa "echo 'SSH connection successful'" + ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/.ssh/id_ed25519 svc_github@uz.saya.casa "echo 'SSH connection successful'" - name: Set github short sha id: ghss_vars -- cgit v1.3.1+13 From 38cb561f5f9048d26ac7f38176c928fd4e7f32df Mon Sep 17 00:00:00 2001 From: SayaAndy Date: Mon, 4 May 2026 15:50:53 +0700 Subject: feat: enable gha buildx cache fix: use sha short from single source --- .github/workflows/build-and-deploy-prod.yml | 5 ++++- .github/workflows/build-and-deploy-stage.yml | 15 ++++++++------- Dockerfile | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build-and-deploy-prod.yml b/.github/workflows/build-and-deploy-prod.yml index 4689e28..d33f7af 100644 --- a/.github/workflows/build-and-deploy-prod.yml +++ b/.github/workflows/build-and-deploy-prod.yml @@ -40,6 +40,8 @@ jobs: context: . file: ./Dockerfile push: true + cache-from: type=gha + cache-to: type=gha,mode=max tags: | ghcr.io/sayaandy/saya-today-web:latest ghcr.io/sayaandy/saya-today-web:stable @@ -87,8 +89,9 @@ jobs: working-directory: ./deploy run: | ansible-playbook \ + playbook.yml \ -i inventory.yml \ - -l prod playbook.yml \ + -l prod \ --private-key ~/.ssh/id_ed25519 \ -u svc_github \ -e saya_today_web_auth_salt="${{ secrets.AUTH_SALT }}" \ diff --git a/.github/workflows/build-and-deploy-stage.yml b/.github/workflows/build-and-deploy-stage.yml index f81212a..ce4a1fb 100644 --- a/.github/workflows/build-and-deploy-stage.yml +++ b/.github/workflows/build-and-deploy-stage.yml @@ -9,6 +9,8 @@ jobs: environment: Stage permissions: packages: write + outputs: + sha_short: ${{ steps.ghss_vars.outputs.sha_short }} steps: - name: Checkout uses: actions/checkout@v6 @@ -35,7 +37,7 @@ jobs: - name: Set github short sha id: ghss_vars - run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + run: echo "sha_short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT - name: Build and push uses: docker/build-push-action@v7 @@ -43,6 +45,8 @@ jobs: context: . file: ./Dockerfile push: true + cache-from: type=gha + cache-to: type=gha,mode=max tags: | ghcr.io/sayaandy/saya-today-web:latest ghcr.io/sayaandy/saya-today-web:commit-${{ steps.ghss_vars.outputs.sha_short }} @@ -77,25 +81,22 @@ jobs: run: | ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/.ssh/id_ed25519 svc_github@uz.saya.casa "echo 'SSH connection successful'" - - name: Set github short sha - id: ghss_vars - run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - name: Run Ansible playbook env: ANSIBLE_HOST_KEY_CHECKING: "False" working-directory: ./deploy run: | ansible-playbook \ + playbook.yml \ -i inventory.yml \ - -l stage playbook.yml \ + -l stage \ --private-key ~/.ssh/id_ed25519 \ -u svc_github \ -e saya_today_web_auth_salt="${{ secrets.AUTH_SALT }}" \ -e saya_today_web_s3_access_key_id="${{ secrets.S3_ACCESS_KEY_ID }}" \ -e saya_today_web_s3_secret_access_key="${{ secrets.S3_SECRET_ACCESS_KEY }}" \ -e saya_today_web_environment=stage \ - -e saya_today_web_tag=commit-${{ steps.ghss_vars.outputs.sha_short }} \ + -e saya_today_web_tag=commit-${{ needs.build-and-push.outputs.sha_short }} \ -e saya_today_web_mail_salt="${{ secrets.MAIL_SALT }}" \ -e saya_today_web_mail_host="${{ secrets.MAIL_HOST }}" \ -e saya_today_web_mail_address="${{ secrets.MAIL_ADDRESS }}" \ diff --git a/Dockerfile b/Dockerfile index 5c38111..318ca51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ RUN apk add --no-cache sqlite-dev musl-dev gcc WORKDIR /builddir COPY . . +RUN go mod download RUN CGO_ENABLED=1 go build -o sayana-web . FROM alpine:3.23 AS runtime-stage -- cgit v1.3.1+13