Skip to content

Commit 30f8fbe

Browse files
author
Dorazil
committed
Přidej nasazovací systém pomocí Deployer a zjednoduš workflow
1 parent 3668632 commit 30f8fbe

File tree

3 files changed

+333
-154
lines changed

3 files changed

+333
-154
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Deploy template
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
required: true
8+
type: string
9+
root_dir:
10+
required: true
11+
type: string
12+
ssh_username:
13+
required: true
14+
type: string
15+
host:
16+
required: true
17+
type: string
18+
port:
19+
required: false
20+
type: string
21+
default: "22"
22+
secrets:
23+
DEPLOY_SSH_KEY:
24+
required: true
25+
CONFIG_DATABASE_PASSWORD:
26+
required: true
27+
CONFIG_GOOGLE_CREDENTIALS:
28+
required: true
29+
CONFIG_APPLICATION_ID:
30+
required: false
31+
CONFIG_SENTRY_DSN:
32+
required: false
33+
34+
jobs:
35+
deploy:
36+
runs-on: ubuntu-22.04
37+
container:
38+
build:
39+
context: ./containers/deploy
40+
steps:
41+
- name: Download workdir
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: workdir
45+
path: .
46+
- name: Extract workdir
47+
run: tar -xzpf workdir.tar.gz
48+
49+
- name: Setup SSH authentication
50+
run: |
51+
mkdir -p ~/.ssh && chmod 700 ~/.ssh
52+
eval $(ssh-agent -s)
53+
echo "$PRIVATE_KEY" | tr -d '\r' | ssh-add -
54+
env:
55+
PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
56+
57+
- name: Run deploy
58+
run: ./dep deploy ${{ inputs.environment }} -vvv
59+
env:
60+
ENVIRONMENT: ${{ inputs.environment }}
61+
ROOT_DIR: ${{ inputs.root_dir }}
62+
SSH_USERNAME: ${{ inputs.ssh_username }}
63+
HOST: ${{ inputs.host }}
64+
PORT: ${{ inputs.port }}
65+
CONFIG_APPLICATION_ID: ${{ secrets.CONFIG_APPLICATION_ID }}
66+
CONFIG_DATABASE_PASSWORD: ${{ secrets.CONFIG_DATABASE_PASSWORD }}
67+
CONFIG_GOOGLE_CREDENTIALS: ${{ secrets.CONFIG_GOOGLE_CREDENTIALS }}
68+
CONFIG_SENTRY_DSN: ${{ secrets.CONFIG_SENTRY_DSN }}
69+
GITHUB_SHA: ${{ github.sha }}

.github/workflows/main.yml

Lines changed: 46 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -314,157 +314,49 @@ jobs:
314314
steps:
315315
- run: true
316316

317-
deploy-beta:
318-
name: "Deploy to beta-h.skauting.cz"
319-
if: github.ref == 'refs/heads/beta'
320-
needs: [checks-passed]
321-
runs-on: ubuntu-22.04
322-
container:
323-
image: skaut/lebeda:8.2-ci
324-
steps:
325-
- name: Debug branch
326-
run: |
327-
echo "Current ref: $GITHUB_REF"
328-
- name: Download workdir
329-
uses: actions/download-artifact@v4
330-
with:
331-
name: workdir
332-
path: .
333-
- name: Extract workdir
334-
run: tar -xzpf workdir.tar.gz
335-
- name: Setup SSH authentication
336-
run: .github/workflows/setup_ssh.sh "$DEPLOY_SSH_KEY" "$SSH_KEY_FILE"
337-
env:
338-
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
339-
SSH_KEY_FILE: /root/.ssh/id_key
340-
341-
# Copy & paste from https://github.com/actions/cache/blob/master/examples.md#node---yarn
342-
- name: Get yarn cache
343-
id: yarn-cache
344-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
345-
346-
- uses: actions/cache@v4
347-
with:
348-
path: ${{ steps.yarn-cache.outputs.dir }}
349-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
350-
restore-keys: |
351-
${{ runner.os }}-yarn-
352-
- name: Install Node.js
353-
uses: actions/setup-node@v4
354-
with:
355-
node-version: '20'
356-
357-
- name: Setup git safe dir
358-
run: git config --global --add safe.directory /__w/${GITHUB_REPOSITORY#*/}/${GITHUB_REPOSITORY#*/}
359-
360-
- name: Deploy to beta-h.skauting.cz
361-
run: phing deploy
362-
env:
363-
ENVIRONMENT: beta
364-
ROOT_DIR: /home/vu011961
365-
SSH_USERNAME: vu011961
366-
SSH_KEY_FILE: /root/.ssh/id_key
367-
CONFIG_APPLICATION_ID: ${{ secrets.CONFIG_BETA_SKAUTIS_APPLICATION_ID }}
368-
CONFIG_DATABASE_PASSWORD: ${{ secrets.CONFIG_BETA_DATABASE_PASSWORD }}
369-
CONFIG_GOOGLE_CREDENTIALS: ${{ secrets.CONFIG_BETA_GOOGLE_CREDENTIALS }}
370-
371-
deploy-test:
372-
name: "Deploy to test-h.skauting.cz"
373-
if: github.ref == 'refs/heads/master'
374-
needs: [checks-passed]
375-
runs-on: ubuntu-22.04
376-
container:
377-
image: skaut/lebeda:8.1-ci
378-
steps:
379-
- name: Download workdir
380-
uses: actions/download-artifact@v4
381-
with:
382-
name: workdir
383-
path: .
384-
- name: Extract workdir
385-
run: tar -xzpf workdir.tar.gz
386-
- name: Setup SSH authentication
387-
run: .github/workflows/setup_ssh.sh "$DEPLOY_SSH_KEY" "$SSH_KEY_FILE"
388-
env:
389-
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
390-
SSH_KEY_FILE: /root/.ssh/id_key
391-
392-
# Copy & paste from https://github.com/actions/cache/blob/master/examples.md#node---yarn
393-
- name: Get yarn cache
394-
id: yarn-cache
395-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
396-
397-
- uses: actions/cache@v4
398-
with:
399-
path: ${{ steps.yarn-cache.outputs.dir }}
400-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
401-
restore-keys: |
402-
${{ runner.os }}-yarn-
403-
- name: Install Node.js
404-
uses: actions/setup-node@v4
405-
with:
406-
node-version: '20'
407-
408-
- name: Setup git safe dir
409-
run: git config --global --add safe.directory /__w/${GITHUB_REPOSITORY#*/}/${GITHUB_REPOSITORY#*/}
410-
411-
- name: Deploy to test-h.skauting.cz
412-
run: phing deploy
413-
env:
414-
ENVIRONMENT: test
415-
ROOT_DIR: /home/vu009010
416-
SSH_USERNAME: vu009010
417-
SSH_KEY_FILE: /root/.ssh/id_key
418-
CONFIG_DATABASE_PASSWORD: ${{ secrets.CONFIG_TEST_DATABASE_PASSWORD }}
419-
CONFIG_GOOGLE_CREDENTIALS: ${{ secrets.CONFIG_TEST_GOOGLE_CREDENTIALS }}
420-
421-
deploy-production:
422-
name: "Deploy to h.skauting.cz"
423-
if: github.ref == 'refs/heads/master'
424-
needs: [checks-passed]
425-
runs-on: ubuntu-22.04
426-
container:
427-
image: skaut/lebeda:8.2-ci
428-
steps:
429-
- name: Download workdir
430-
uses: actions/download-artifact@v4
431-
with:
432-
name: workdir
433-
path: .
434-
- name: Extract workdir
435-
run: tar -xzpf workdir.tar.gz
436-
- name: Setup SSH authentication
437-
run: .github/workflows/setup_ssh.sh "$DEPLOY_SSH_KEY" "$SSH_KEY_FILE"
438-
env:
439-
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
440-
SSH_KEY_FILE: /root/.ssh/id_key
441-
442-
# Copy & paste from https://github.com/actions/cache/blob/master/examples.md#node---yarn
443-
- name: Get yarn cache
444-
id: yarn-cache
445-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
446-
447-
- uses: actions/cache@v4
448-
with:
449-
path: ${{ steps.yarn-cache.outputs.dir }}
450-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
451-
restore-keys: |
452-
${{ runner.os }}-yarn-
453-
- name: Install Node.js
454-
uses: actions/setup-node@v4
455-
with:
456-
node-version: '20'
457-
458-
- name: Setup git safe dir
459-
run: git config --global --add safe.directory /__w/${GITHUB_REPOSITORY#*/}/${GITHUB_REPOSITORY#*/}
460-
461-
- name: Deploy to h.skauting.cz
462-
run: phing deploy
463-
env:
464-
ENVIRONMENT: production
465-
ROOT_DIR: /home/vu008930
466-
SSH_USERNAME: vu008930
467-
SSH_KEY_FILE: /root/.ssh/id_key
468-
CONFIG_DATABASE_PASSWORD: ${{ secrets.CONFIG_PRODUCTION_DATABASE_PASSWORD }}
469-
CONFIG_SENTRY_DSN: ${{ secrets.CONFIG_SENTRY_DSN }}
470-
CONFIG_GOOGLE_CREDENTIALS: ${{ secrets.CONFIG_PRODUCTION_GOOGLE_CREDENTIALS }}
317+
deploy-beta:
318+
if: github.ref == 'refs/heads/beta'
319+
needs: [checks-passed]
320+
uses: ./.github/workflows/deploy-template.yml
321+
with:
322+
environment: beta
323+
root_dir: /home/vu011961
324+
ssh_username: vu011961
325+
host: www.skauting.cz
326+
port: "11961"
327+
secrets:
328+
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
329+
CONFIG_APPLICATION_ID: ${{ secrets.CONFIG_BETA_SKAUTIS_APPLICATION_ID }}
330+
CONFIG_DATABASE_PASSWORD: ${{ secrets.CONFIG_BETA_DATABASE_PASSWORD }}
331+
CONFIG_GOOGLE_CREDENTIALS: ${{ secrets.CONFIG_BETA_GOOGLE_CREDENTIALS }}
332+
333+
deploy-test:
334+
if: github.ref == 'refs/heads/master'
335+
needs: [checks-passed]
336+
uses: ./.github/workflows/deploy-template.yml
337+
with:
338+
environment: test
339+
root_dir: /home/vu009010
340+
ssh_username: vu009010
341+
host: www.skauting.cz
342+
port: "9010"
343+
secrets:
344+
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
345+
CONFIG_DATABASE_PASSWORD: ${{ secrets.CONFIG_TEST_DATABASE_PASSWORD }}
346+
CONFIG_GOOGLE_CREDENTIALS: ${{ secrets.CONFIG_TEST_GOOGLE_CREDENTIALS }}
347+
348+
deploy-production:
349+
if: github.ref == 'refs/heads/master'
350+
needs: [checks-passed]
351+
uses: ./.github/workflows/deploy-template.yml
352+
with:
353+
environment: production
354+
root_dir: /home/vu008930
355+
ssh_username: vu008930
356+
host: www.skauting.cz
357+
port: 8930
358+
secrets:
359+
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
360+
CONFIG_DATABASE_PASSWORD: ${{ secrets.CONFIG_PRODUCTION_DATABASE_PASSWORD }}
361+
CONFIG_GOOGLE_CREDENTIALS: ${{ secrets.CONFIG_PRODUCTION_GOOGLE_CREDENTIALS }}
362+
CONFIG_SENTRY_DSN: ${{ secrets.CONFIG_SENTRY_DSN }}

0 commit comments

Comments
 (0)