Skip to content

Commit 3063328

Browse files
loffaCactooz
authored andcommitted
Update deployment workflow
1 parent eea4869 commit 3063328

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

Diff for: .github/workflows/build-deploy.yml

+31-23
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
11
name: Build and deploy
22

33
on:
4-
workflow_run:
5-
workflows: [Test]
6-
branches: [master]
7-
types: [completed]
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- '*'
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
813

914
jobs:
1015
deploy:
11-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1216
name: Deploy
1317
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
1421
steps:
15-
- name: Build container
16-
id: docker_build
17-
uses: docker/build-push-action@v2
22+
- name: Login to GitHub Container Registry
23+
uses: docker/login-action@v3
1824
with:
19-
load: true
20-
tags: insektionen/songbook-2.0:latest
21-
- name: Export container
22-
run: docker save insektionen/songbook-2.0:latest | gzip > songbook-2.0_latest.tar.gz
23-
- name: Copy to Server
24-
uses: appleboy/scp-action@master
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
- name: Extract metadata (tags, labels) for Docker
29+
id: meta
30+
uses: docker/metadata-action@v5
2531
with:
26-
host: ${{ secrets.SSH_HOST }}
27-
username: ${{ secrets.SSH_USERNAME }}
28-
key: ${{ secrets.SSH_KEY }}
29-
port: 22
30-
source: 'songbook-2.0_latest.tar.gz'
31-
target: '~/'
32-
- name: Import and start on Server
32+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
33+
- name: Build container
34+
uses: docker/build-push-action@v5
35+
with:
36+
push: true
37+
tags: ${{ steps.meta.outputs.tags }}
38+
labels: ${{ steps.meta.outputs.labels }}
39+
- name: Start on Server
3340
uses: appleboy/ssh-action@master
3441
with:
3542
host: ${{ secrets.SSH_HOST }}
3643
username: ${{ secrets.SSH_USERNAME }}
3744
key: ${{ secrets.SSH_KEY }}
38-
port: 22
39-
script: docker load < songbook-2.0_latest.tar.gz && cd songbook-2.0 && docker-compose up -d
45+
port: 2222
46+
envs: GITHUB_TOKEN,GITHUB_ACTOR
47+
script: "cd songbook-2.0 && echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin && docker compose up -d"

0 commit comments

Comments
 (0)