Skip to content

Commit 388153a

Browse files
committed
refactor: simplify github actions and workflows organisation
- split actions into utility and workflow-actions - combine previous workflows into 'staging' and 'production'
1 parent 168c4cb commit 388153a

File tree

16 files changed

+262
-392
lines changed

16 files changed

+262
-392
lines changed

.github/actions/pnpm-install/action.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: 🌐 Backend action
2+
description: This action builds, tests, and pushes the backend Docker image.
3+
4+
inputs:
5+
go-version:
6+
description: The version of Go to use.
7+
required: true
8+
build-path:
9+
description: The path to the build directory.
10+
required: true
11+
test-path:
12+
description: The path to the test directory.
13+
required: true
14+
output-name:
15+
description: The name of the output file.
16+
required: true
17+
tag:
18+
description: The tag to push to the Docker registry.
19+
required: true
20+
dockerhub_username:
21+
description: The username for my docker account.
22+
required: true
23+
dockerhub_token:
24+
description: The token for my docker account.
25+
required: true
26+
folder:
27+
description: The folder where resides the dockerfile.
28+
required: true
29+
30+
runs:
31+
using: composite
32+
steps:
33+
- name: install pnpm
34+
uses: pnpm/action-setup@v4
35+
with:
36+
version: 9.0.5
37+
- uses: actions/setup-node@v4
38+
with:
39+
node-version: 20.11.1
40+
cache: 'pnpm'
41+
cache-dependency-path: './frontend/pnpm-lock.yaml'
42+
- name: ⬣ Build
43+
working-directory: ./backend
44+
uses: ./.github/actions/utility-actions/go-build
45+
with:
46+
go-version: ${{ inputs.go-version }}
47+
build-path: ${{ inputs.build-path }}
48+
output-name: ${{ inputs.output-name }}
49+
- name: 🧪 Golang tests
50+
working-directory: ./backend
51+
uses: ./.github/actions/utility-actions/go-test
52+
with:
53+
go-version: ${{ inputs.go-version }}
54+
test-path: ${{ inputs.test-path }}
55+
- name: Push backend docker application to container registry
56+
uses: ./.github/actions/utility-actions/push-docker-image
57+
with:
58+
tag: ${{ inputs.tag }}
59+
dockerhub_username: ${{ inputs.dockerhub_username }}
60+
dockerhub_token: ${{ inputs.dockerhub_token }}
61+
folder: ${{ inputs.folder }}

.github/actions/deploy/action.yaml renamed to .github/actions/workflow-actions/deploy-app/action.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 🚀 Deploy application
2-
description: Build and push a docker image to docker hub.
2+
description: This action deploys the application by pulling the latest Docker images from the container registry, removing existing containers, and starting the services. It also includes health checks and cleanup of unused resources.
33

44
inputs:
55
filter:
@@ -11,9 +11,6 @@ inputs:
1111
dockerhub_token:
1212
description: Docker Hub access token for authentication
1313
required: true
14-
compose_file:
15-
description: Name of the Docker Compose file without the .compose.yaml extension
16-
required: true
1714
app_env:
1815
description: Application environment (e.g., 'staging' or 'production')
1916
required: true
@@ -96,7 +93,7 @@ runs:
9693
docker pull henga/leviosa:${{ inputs.app_env }}-backend
9794
9895
echo "Starting services..."
99-
docker compose -f ${{ inputs.compose_file }}.yaml up -d --force-recreate
96+
docker compose up -d --force-recreate
10097
10198
echo "Waiting for services to be healthy..."
10299
attempt_counter=0
@@ -105,7 +102,7 @@ runs:
105102
until curl --output /dev/null --silent --fail ${{ inputs.public_url }}/health; do
106103
if [ ${attempt_counter} -eq ${max_attempts} ]; then
107104
echo "ERROR: Application failed to become healthy after 2 minutes"
108-
docker compose -f ${{ inputs.compose_file }}.compose.yaml logs
105+
docker compose logs
109106
exit 1
110107
fi
111108
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: 🌐 Frontend action
2+
description: This action builds, tests, and pushes the frontend Docker image.
3+
4+
inputs:
5+
tag:
6+
description: The tag to push to the Docker registry.
7+
required: true
8+
dockerhub_username:
9+
description: The username for my docker account.
10+
required: true
11+
dockerhub_token:
12+
description: The token for my docker account.
13+
required: true
14+
folder:
15+
description: The folder where resides the dockerfile.
16+
required: true
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: install pnpm
22+
uses: pnpm/action-setup@v4
23+
with:
24+
version: 9.0.5
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: 20.11.1
28+
cache: 'pnpm'
29+
cache-dependency-path: './frontend/pnpm-lock.yaml'
30+
- name: Install dependencies
31+
working-directory: ./frontend
32+
run: pnpm install
33+
shell: bash
34+
# - name: 🔬 Lint
35+
# working-directory: ./frontend
36+
# run: pnpm run lint
37+
# - name: 🔎 Type check
38+
# working-directory: ./frontend
39+
# run: pnpm run check
40+
# - name: Update apt and install dependencies
41+
# working-directory: ./frontend
42+
# run: |
43+
# apt-get update
44+
# apt-get install -y libenchant-dev libicu-dev libjpeg-turbo-official32=2.2 libvpx-dev libevent-dev
45+
# - name: Install playwright browsers
46+
# working-directory: ./frontend
47+
# run: pnpm exec playwright install --with-deps
48+
# - name: 🔎 Integration test
49+
# working-directory: ./frontend
50+
# run: pnpm run test:integration
51+
- name: 🔎 Unit test
52+
working-directory: ./frontend
53+
run: pnpm run test:unit
54+
- name: Push frontend docker application to container registry
55+
uses: ./.github/actions/utility-actions/push-docker-image
56+
with:
57+
tag: ${{ inputs.tag }}
58+
dockerhub_username: ${{ inputs.dockerhub_username }}
59+
dockerhub_token: ${{ inputs.dockerhub_token }}
60+
folder: ${{ inputs.folder }}

.github/workflows/back.yaml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/deploy-vps.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/front.yaml

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)