-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (46 loc) · 1.28 KB
/
Copy pathdeploy.yml
File metadata and controls
55 lines (46 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Docker CI/CD (No SSH)
on:
push:
branches: ["main"]
paths-ignore:
- "README.md"
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set image name (lowercase)
id: img
run: |
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
- name: Build & Push Image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/aspilgi/devlog:latest
ghcr.io/aspilgi/devlog:${{ github.sha }}
deploy:
needs: build-and-push
runs-on: [self-hosted]
steps:
- name: Deploy on EC2 with Docker Compose
run: |
set -e
cd /opt/devlog
docker compose pull
docker compose up -d --force-recreate --remove-orphans
docker image prune -f
docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}"