Skip to content

Commit 6d617f7

Browse files
chore(cicd): update deploy workflows
1 parent c983ac4 commit 6d617f7

File tree

7 files changed

+165
-146
lines changed

7 files changed

+165
-146
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ name: "CodeQL"
77

88
on:
99
push:
10-
branches: [master]
10+
branches: [main]
1111
pull_request:
1212
# The branches below must be a subset of the branches above
13-
branches: [master]
13+
branches: [main]
1414
schedule:
15-
- cron: '0 21 * * 4'
15+
- cron: "0 21 * * 4"
1616

1717
jobs:
1818
analyze:
@@ -24,48 +24,48 @@ jobs:
2424
matrix:
2525
# Override automatic language detection by changing the below list
2626
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
27-
language: ['javascript', 'python']
27+
language: ["javascript", "python"]
2828
# Learn more...
2929
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
3030

3131
steps:
32-
- name: Checkout repository
33-
uses: actions/checkout@v2
34-
with:
35-
# We must fetch at least the immediate parents so that if this is
36-
# a pull request then we can checkout the head.
37-
fetch-depth: 2
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
with:
35+
# We must fetch at least the immediate parents so that if this is
36+
# a pull request then we can checkout the head.
37+
fetch-depth: 2
3838

39-
# If this run was triggered by a pull request event, then checkout
40-
# the head of the pull request instead of the merge commit.
41-
- run: git checkout HEAD^2
42-
if: ${{ github.event_name == 'pull_request' }}
39+
# If this run was triggered by a pull request event, then checkout
40+
# the head of the pull request instead of the merge commit.
41+
- run: git checkout HEAD^2
42+
if: ${{ github.event_name == 'pull_request' }}
4343

44-
# Initializes the CodeQL tools for scanning.
45-
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v1
47-
with:
48-
languages: ${{ matrix.language }}
49-
# If you wish to specify custom queries, you can do so here or in a config file.
50-
# By default, queries listed here will override any specified in a config file.
51-
# Prefix the list here with "+" to use these queries and those in the config file.
52-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
44+
# Initializes the CodeQL tools for scanning.
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@v1
47+
with:
48+
languages: ${{ matrix.language }}
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5353

54-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55-
# If this step fails, then you should remove it and run the build manually (see below)
56-
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v1
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v1
5858

59-
# ℹ️ Command-line programs to run using the OS shell.
60-
# 📚 https://git.io/JvXDl
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
6161

62-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63-
# and modify them (or add more) to build your code if your project
64-
# uses a compiled language
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
6565

66-
#- run: |
67-
# make bootstrap
68-
# make release
66+
#- run: |
67+
# make bootstrap
68+
# make release
6969

70-
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v1
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v1
Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,61 @@ name: Login into host machine, build and start the app's daemon
22
on:
33
push:
44
branches:
5-
- prd-host
5+
- bare-metal-deploy
66

77
jobs:
88
build-frontend:
99
runs-on: ubuntu-latest
10-
strategy:
11-
matrix:
12-
node-version: [12.x]
1310
steps:
14-
- uses: actions/checkout@v2
15-
- name: Use Node.js ${{ matrix.node-version }}
16-
uses: actions/setup-node@v1
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- uses: pnpm/action-setup@v4
14+
name: Install pnpm
1715
with:
18-
node-version: ${{ matrix.node-version }}
19-
- run: cd frontend && npm ci
20-
- run: cd frontend && npm run check --if-present
21-
- run: cd frontend && npm run test:static --if-present
22-
- run: cd frontend && npm test --if-present
23-
- run: cd frontend && sudo npm run build --if-present
24-
25-
build-django:
16+
version: 8
17+
run_install: false
18+
- name: Install Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
cache: "pnpm"
23+
- name: Get pnpm store directory
24+
shell: bash
25+
run: |
26+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
27+
- uses: actions/cache@v4
28+
name: Setup pnpm cache
29+
with:
30+
path: ${{ env.STORE_PATH }}
31+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
32+
restore-keys: |
33+
${{ runner.os }}-pnpm-store-
34+
- name: Install dependencies
35+
working-directory: ./frontend
36+
run: pnpm install
37+
- name: Build frontend
38+
working-directory: ./frontend
39+
run: pnpm build
40+
41+
build-backend:
2642
runs-on: ubuntu-latest
2743
needs: build-frontend
28-
strategy:
29-
max-parallel: 4
30-
matrix:
31-
python-version: [3.8]
3244
steps:
33-
- uses: actions/checkout@v2
34-
- name: Setup Memcache
35-
run: sudo apt-get install libmemcached-dev
36-
- name: Set up Python ${{ matrix.python-version }}
37-
uses: actions/setup-python@v1
45+
- uses: actions/checkout@v4
46+
- name: Set up Python
47+
uses: actions/setup-python@v4
3848
with:
39-
python-version: ${{ matrix.python-version }}
40-
- name: Install Dependencies
49+
python-version: 3.12
50+
- name: Install dependencies
4151
run: |
42-
4352
python -m pip install --upgrade pip
44-
pip install -r requirements.txt
53+
pip install poetry
54+
poetry install --no-dev
4555
- name: Run Tests
4656
env:
4757
TEST: 1
4858
run: |
49-
python manage.py test
59+
poetry run python manage.py test
5060
5161
deploy:
5262
runs-on: ubuntu-latest
Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
# Publish `prd` as Docker `latest` image.
66
branches:
7-
- prd
7+
- vm-deploy-prod
88

99
# Publish `v1.2.3` tags as releases.
1010
tags:
@@ -14,63 +14,69 @@ on:
1414
pull_request:
1515

1616
jobs:
17-
# Run tests.
18-
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
1917
build-frontend:
2018
runs-on: ubuntu-latest
21-
strategy:
22-
matrix:
23-
node-version: [12.x]
2419
steps:
25-
- uses: actions/checkout@v2
26-
- name: Use Node.js ${{ matrix.node-version }}
27-
uses: actions/setup-node@v1
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
- uses: pnpm/action-setup@v4
23+
name: Install pnpm
24+
with:
25+
version: 8
26+
run_install: false
27+
- name: Install Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
cache: "pnpm"
32+
- name: Get pnpm store directory
33+
shell: bash
34+
run: |
35+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
36+
- uses: actions/cache@v4
37+
name: Setup pnpm cache
2838
with:
29-
node-version: ${{ matrix.node-version }}
30-
- run: cd frontend && npm ci
31-
- run: cd frontend && npm run check --if-present
32-
- run: cd frontend && npm run test:static --if-present
33-
- run: cd frontend && npm test --if-present
34-
- run: cd frontend && npm run build --if-present
39+
path: ${{ env.STORE_PATH }}
40+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
41+
restore-keys: |
42+
${{ runner.os }}-pnpm-store-
43+
- name: Install dependencies
44+
working-directory: ./frontend
45+
run: pnpm install
46+
- name: Build frontend
47+
working-directory: ./frontend
48+
run: pnpm build
3549

36-
build-django:
50+
build-backend:
3751
runs-on: ubuntu-latest
3852
needs: build-frontend
39-
strategy:
40-
max-parallel: 4
41-
matrix:
42-
python-version: [3.8]
4353
steps:
44-
- uses: actions/checkout@v2
45-
- name: Set up Python ${{ matrix.python-version }}
46-
uses: actions/setup-python@v1
54+
- uses: actions/checkout@v4
55+
- name: Set up Python
56+
uses: actions/setup-python@v4
4757
with:
48-
python-version: ${{ matrix.python-version }}
49-
- name: Install Dependencies
58+
python-version: 3.12
59+
- name: Install dependencies
5060
run: |
5161
python -m pip install --upgrade pip
52-
pip install -r requirements.txt
62+
pip install poetry
63+
poetry install --no-dev
5364
- name: Run Tests
5465
env:
5566
TEST: 1
5667
run: |
57-
python manage.py test
68+
poetry run python manage.py test
5869
5970
test-image:
6071
runs-on: ubuntu-latest
61-
needs: build-django
72+
needs: build-backend
6273
env:
6374
SECRET_KEY: ${{ secrets.SECRET_KEY }}
6475
steps:
65-
- uses: actions/checkout@v2
76+
- uses: actions/checkout@v4
6677
- name: Run tests
6778
run: |
68-
if [ -f docker-compose.test.yml ]; then
69-
docker-compose --file docker-compose.test.yml build
70-
docker-compose --file docker-compose.test.yml run sut
71-
else
72-
docker build . --build-arg AUTH_TOKEN=${{ secrets.AUTH_KEY }} --build-arg GTAG_ID=${{ secrets.GTAG_ID }} --build-arg ALLOWED_HOSTS=${{ secrets.ALLOWED_HOSTS }} --file Dockerfile
73-
fi
79+
docker build . --build-arg AUTH_TOKEN=${{ secrets.AUTH_KEY }}--build-arg ALLOWED_HOSTS=${{ secrets.ALLOWED_HOSTS }} --file Dockerfile
7480
7581
# Push image to GitHub Packages.
7682
# See also https://docs.docker.com/docker-hub/builds/
@@ -82,7 +88,7 @@ jobs:
8288
steps:
8389
- uses: actions/checkout@v2
8490
- name: Build image
85-
run: docker build . --build-arg AUTH_TOKEN=${{ secrets.AUTH_KEY }} --build-arg GTAG_ID=${{ secrets.GTAG_ID }} --build-arg ALLOWED_HOSTS=${{ secrets.ALLOWED_HOSTS }} --file Dockerfile --tag ${{ secrets.IMAGE_NAME }}
91+
run: docker build . --build-arg AUTH_TOKEN=${{ secrets.AUTH_KEY }} --build-arg ALLOWED_HOSTS=${{ secrets.ALLOWED_HOSTS }} --file Dockerfile --tag ${{ secrets.IMAGE_NAME }}
8692
- name: Log into registry
8793
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
8894
- name: Push image
@@ -140,7 +146,7 @@ jobs:
140146
key: ${{ secrets.SSH_PRIVATE_KEY }}
141147
port: 22
142148
script: |
143-
docker login -u marcelovicentegc -p ${{ secrets.DEPLOY_TOKEN }} docker.pkg.github.com
149+
docker login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.DEPLOY_TOKEN }} docker.pkg.github.com
144150
cd image
145151
docker-compose pull
146152
MODE=production SMTP_HOST_USER=${{ secrets.SMTP_HOST_USER }} SMTP_HOST_PASSWORD=${{ secrets.SMTP_HOST_PASSWORD }} SECRET_KEY=${{ secrets.SECRET_KEY }} CDN_NAME=${{ secrets.CDN_NAME }} CDN_API_KEY=${{ secrets.CDN_API_KEY }} CDN_API_SECRET=${{ secrets.CDN_API_SECRET }} DB_HOST=${{ secrets.DB_HOST }} DB_NAME=${{ secrets.DB_NAME }} DB_USER=${{ secrets.DB_USER }} DB_PASSWORD=${{ secrets.DB_PASSWORD }} DB_PORT=${{ secrets.DB_PORT }} docker-compose up -d

0 commit comments

Comments
 (0)