Skip to content

Commit 5b25ea4

Browse files
authored
Refactor GitHub Actions workflow for deployment
1 parent 8f60977 commit 5b25ea4

1 file changed

Lines changed: 44 additions & 6 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,60 @@ on:
44
push:
55
branches:
66
- dev
7-
87
workflow_dispatch:
98

9+
concurrency:
10+
group: mudextensions-deploy
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
packages: write
16+
1017
jobs:
11-
deploy:
18+
build-and-deploy:
1219
runs-on: ubuntu-latest
1320

1421
steps:
15-
- name: Deploy to Server via SSH
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Login to GitHub Container Registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Setup Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Build and push image
36+
uses: docker/build-push-action@v6
37+
with:
38+
context: .
39+
push: true
40+
tags: |
41+
ghcr.io/codebeamorg/codebeam.mudblazor.extensions:dev
42+
ghcr.io/codebeamorg/codebeam.mudblazor.extensions:${{ github.sha }}
43+
cache-from: type=gha
44+
cache-to: type=gha,mode=max
45+
46+
- name: Deploy to Server
1647
uses: appleboy/ssh-action@v1.0.3
1748
with:
1849
host: ${{ secrets.SERVER_HOST }}
1950
username: ${{ secrets.SERVER_USER }}
2051
key: ${{ secrets.SSH_PRIVATE_KEY }}
2152
script: |
53+
set -e
54+
2255
cd ~/apps/CodeBeam.MudBlazor.Extensions
23-
git pull origin dev
24-
docker compose up -d --build
25-
56+
57+
git fetch origin dev
58+
git reset --hard origin/dev
59+
60+
docker compose pull
61+
docker compose up -d --remove-orphans
62+
63+
docker image prune -f

0 commit comments

Comments
 (0)