Skip to content

Commit 6d34da5

Browse files
authored
update
1 parent 0f45851 commit 6d34da5

File tree

1 file changed

+35
-174
lines changed

1 file changed

+35
-174
lines changed

.github/workflows/pipeline.yml

+35-174
Original file line numberDiff line numberDiff line change
@@ -10,179 +10,40 @@ jobs:
1010
bump:
1111
uses: UnterrainerInformatik/bump-semver-workflow/.github/workflows/workflow.yml@master
1212
build:
13-
name: Build 🔨
14-
runs-on: [self-hosted, Linux, X64]
15-
needs: [bump]
16-
steps:
17-
- name: Pre-fetch upload-artifact action (self-hosted only) ⚙️
18-
if: contains(runner.labels, 'self-hosted')
19-
run: |
20-
mkdir -p ~/.setup-actions
21-
cd ~/.setup-actions
22-
if [ ! -d "upload-artifact" ]; then
23-
echo "Cloning upload-artifact@v4..."
24-
git clone --depth=1 --branch v4 https://github.com/actions/upload-artifact.git upload-artifact
25-
echo "✅ upload-artifact@v4 cloned manually!"
26-
else
27-
echo "✅ upload-artifact already fetched."
28-
fi
29-
- name: Checkout repo 📦
30-
uses: actions/checkout@v4
31-
- name: Cache Node.js modules 💾
32-
uses: actions/cache@v3
33-
with:
34-
path: ~/.npm
35-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
36-
restore-keys: |
37-
${{ runner.os }}-node-
38-
- name: Set up Node ⚙️
39-
uses: actions/setup-node@v4
40-
with:
41-
node-version-file: '.nvmrc'
42-
cache: 'npm'
43-
cache-dependency-path: 'package-lock.json'
44-
- name: Update version in package.json 💾
45-
uses: reedyuk/[email protected]
46-
with:
47-
version: ${{ needs.bump.outputs.major_version }}.${{ needs.bump.outputs.minor_version }}.${{ needs.bump.outputs.build_version }}
48-
- name: build (install dependencies) ⚙️
49-
run: |
50-
npm install
51-
- name: build (build) 🔨
52-
run: |
53-
npm run build
54-
- name: Upload build artifacts ⬆️
55-
uses: actions/upload-artifact@v4
56-
with:
57-
name: build-artifacts
58-
path: ./dist
59-
13+
uses: UnterrainerInformatik/npm-build-workflow/.github/workflows/workflow.yml@master
14+
needs: bump
15+
with:
16+
major_version: ${{ needs.bump.outputs.major_version }}
17+
minor_version: ${{ needs.bump.outputs.minor_version }}
18+
build_version: ${{ needs.bump.outputs.build_version }}
6019
docker-build:
61-
name: Build Docker Image 🐋
62-
runs-on: [self-hosted, Linux, X64]
63-
needs: [build, bump]
64-
steps:
65-
- name: Pre-fetch upload-artifact action (self-hosted only) ⚙️
66-
if: contains(runner.labels, 'self-hosted')
67-
run: |
68-
mkdir -p ~/.setup-actions
69-
cd ~/.setup-actions
70-
if [ ! -d "upload-artifact" ]; then
71-
echo "Cloning upload-artifact@v4..."
72-
git clone --depth=1 --branch v4 https://github.com/actions/upload-artifact.git upload-artifact
73-
echo "✅ upload-artifact@v4 cloned manually!"
74-
else
75-
echo "✅ upload-artifact already fetched."
76-
fi
77-
- name: Checkout repo 📦
78-
uses: actions/checkout@v4
79-
- name: Download build artifacts ⬇️
80-
uses: actions/download-artifact@v4
81-
with:
82-
name: build-artifacts
83-
path: dist
84-
- name: Setup QEMU ⚙️
85-
uses: docker/setup-qemu-action@v3
86-
- name: Set up Docker Buildx ⚙️
87-
uses: docker/setup-buildx-action@v3
88-
- name: Login to DockerHub 🔑
89-
uses: docker/login-action@v3
90-
with:
91-
username: ${{ secrets.DOCKER_HUB_USER }}
92-
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
93-
- name: test
94-
run: |
95-
echo docker: ${{ secrets.DOCKER_HUB_USER }}/${{ secrets.DOCKER_IMAGE_NAME}}:${{ needs.bump.outputs.major_version }}.${{ needs.bump.outputs.minor_version }}.${{ needs.bump.outputs.build_version }}
96-
- name: Build and push 🔨
97-
uses: docker/build-push-action@v5
98-
with:
99-
context: ./
100-
file: ./Dockerfile
101-
platforms: linux/amd64,linux/arm64/v8
102-
push: true
103-
tags: |
104-
${{ secrets.DOCKER_HUB_USER }}/${{ secrets.DOCKER_IMAGE_NAME}}:latest
105-
${{ secrets.DOCKER_HUB_USER }}/${{ secrets.DOCKER_IMAGE_NAME}}:${{ needs.bump.outputs.major_version }}
106-
${{ secrets.DOCKER_HUB_USER }}/${{ secrets.DOCKER_IMAGE_NAME}}:${{ needs.bump.outputs.major_version }}.${{ needs.bump.outputs.minor_version }}
107-
${{ secrets.DOCKER_HUB_USER }}/${{ secrets.DOCKER_IMAGE_NAME}}:${{ needs.bump.outputs.major_version }}.${{ needs.bump.outputs.minor_version }}.${{ needs.bump.outputs.build_version }}
20+
uses: UnterrainerInformatik/docker-build-workflow/.github/workflows/workflow.yml@master
21+
needs: [bump, build]
22+
with:
23+
major_version: ${{ needs.bump.outputs.major_version }}
24+
minor_version: ${{ needs.bump.outputs.minor_version }}
25+
build_version: ${{ needs.bump.outputs.build_version }}
26+
secrets:
27+
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
28+
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
29+
DOCKER_IMAGE_NAME: ${{ secrets.DOCKER_IMAGE_NAME }}
10830
deploy:
109-
name: Deployment 🚀
110-
runs-on: [self-hosted, Linux, X64]
111-
needs: [docker-build, build, bump]
112-
steps:
113-
- name: Pre-fetch upload-artifact action (self-hosted only) ⚙️
114-
if: contains(runner.labels, 'self-hosted')
115-
run: |
116-
mkdir -p ~/.setup-actions
117-
cd ~/.setup-actions
118-
if [ ! -d "upload-artifact" ]; then
119-
echo "Cloning upload-artifact@v4..."
120-
git clone --depth=1 --branch v4 https://github.com/actions/upload-artifact.git upload-artifact
121-
echo "✅ upload-artifact@v4 cloned manually!"
122-
else
123-
echo "✅ upload-artifact already fetched."
124-
fi
125-
- name: Checkout repo 📦
126-
uses: actions/checkout@v4
127-
- name: Install OpenVPN
128-
run: |
129-
sudo apt update
130-
sudo apt install -y openvpn openvpn-systemd-resolved
131-
- name: Touch OVPN client-config file
132-
run: touch client.ovpn
133-
- name: Fill OVPN client-config file
134-
run: |
135-
echo "${{ secrets.VPN_OVPN_FILE }}" >> client.ovpn
136-
- name: Connect to VPN 🔓
137-
uses: "kota65535/github-openvpn-connect-action@v3"
138-
with:
139-
config_file: client.ovpn
140-
username: ${{ secrets.VPN_USERNAME }}
141-
password: ${{ secrets.VPN_PASSWORD }}
142-
- name: Installing SSH key 🔑
143-
uses: UnterrainerInformatik/setup-ssh-action@v1
144-
with:
145-
key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
146-
- name: Create deploy directory 🚧
147-
uses: UnterrainerInformatik/ssh-mkdir-action@v1
148-
with:
149-
dir: ${{ secrets.DEPLOY_DIR }}
150-
user: ${{ secrets.DEPLOY_SSH_USER }}
151-
host: ${{ secrets.DEPLOY_SERVER }}
152-
port: ${{ secrets.DEPLOY_SSH_PORT }}
153-
- name: Create data directory 🚧
154-
uses: UnterrainerInformatik/ssh-mkdir-action@v1
155-
with:
156-
dir: ${{ secrets.DATA_DIR }}
157-
user: ${{ secrets.DEPLOY_SSH_USER }}
158-
host: ${{ secrets.DEPLOY_SERVER }}
159-
port: ${{ secrets.DEPLOY_SSH_PORT }}
160-
- name: Touch .env file for deployment
161-
run: touch ./deploy/.env
162-
- name: Fill .env file for deployment
163-
run: |
164-
echo VERSION=${{ needs.bump.outputs.version }} >> ./deploy/.env
165-
echo MAJOR_VERSION=${{ needs.bump.outputs.major_version }} >> ./deploy/.env
166-
echo MINOR_VERSION=${{ needs.bump.outputs.minor_version }} >> ./deploy/.env
167-
echo BUILD_VERSION=${{ needs.bump.outputs.build_version }} >> ./deploy/.env
168-
echo DOCKER_HUB_USER=${{ secrets.DOCKER_HUB_USER }} >> ./deploy/.env
169-
echo DOCKER_IMAGE_NAME=${{ secrets.DOCKER_IMAGE_NAME }} >> ./deploy/.env
170-
- name: Deploy using SSH 🚛
171-
uses: UnterrainerInformatik/ssh-deploy-action@v1
172-
with:
173-
source: ./deploy/
174-
target: ${{ secrets.DEPLOY_DIR }}
175-
chmod-mask: 777
176-
chmod-selector: ./deploy/*.sh
177-
user: ${{ secrets.DEPLOY_SSH_USER }}
178-
host: ${{ secrets.DEPLOY_SERVER }}
179-
port: ${{ secrets.DEPLOY_SSH_PORT }}
180-
- name: Run using SSH 🏃
181-
uses: UnterrainerInformatik/ssh-run-action@v1
182-
with:
183-
dir: ${{ secrets.DEPLOY_DIR }}
184-
file: up.sh
185-
user: ${{ secrets.DEPLOY_SSH_USER }}
186-
host: ${{ secrets.DEPLOY_SERVER }}
187-
port: ${{ secrets.DEPLOY_SSH_PORT }}
188-
31+
uses: UnterrainerInformatik/deploy-workflow/.github/workflows/workflow.yml@master
32+
needs: [bump, build, docker-build]
33+
with:
34+
major_version: ${{ needs.bump.outputs.major_version }}
35+
minor_version: ${{ needs.bump.outputs.minor_version }}
36+
build_version: ${{ needs.bump.outputs.build_version }}
37+
secrets:
38+
DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
39+
DEPLOY_SSH_USER: ${{ secrets.DEPLOY_SSH_USER }}
40+
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }}
41+
DEPLOY_SSH_PORT: ${{ secrets.DEPLOY_SSH_PORT }}
42+
DEPLOY_DIR: ${{ secrets.DEPLOY_DIR }}
43+
DATA_DIR: ${{ secrets.DATA_DIR }}
44+
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
45+
DOCKER_IMAGE_NAME: ${{ secrets.DOCKER_IMAGE_NAME }}
46+
# Optional – only when OVPN is needed:
47+
VPN_OVPN_FILE: ${{ secrets.VPN_OVPN_FILE }}
48+
VPN_USERNAME: ${{ secrets.VPN_USERNAME }}
49+
VPN_PASSWORD: ${{ secrets.VPN_PASSWORD }}

0 commit comments

Comments
 (0)