blob: ded8c93995b5b4ef9d5a9f884c48161fba093d53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
name: Docker image building and publishing onto Production
on:
push:
tags:
- "*"
jobs:
build-and-push:
if: github.repository == 'SayaAndy/saya-today-web'
runs-on: ubuntu-latest
environment: Production
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Generate output.css with tailwindcss
uses: ZoeyVid/tailwindcss-update@main
with:
input: static/input.css
output: static/output.css
params: "--minify"
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: true
tags: |
ghcr.io/sayaandy/saya-today-web:latest
ghcr.io/sayaandy/saya-today-web:stable
ghcr.io/sayaandy/saya-today-web:${{ github.ref_name }}
deploy:
if: github.repository == 'SayaAndy/saya-today-web'
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
(cat <<EOF
${{ secrets.SVC_GITHUB_PK }}
EOF
) > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
sed -i 's/\r$//' ~/.ssh/id_ed25519
ssh-keyscan -H uz.saya.casa >> ~/.ssh/known_hosts
- name: Test SSH connection
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: Run Ansible playbook
env:
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 }}"
|