-
Notifications
You must be signed in to change notification settings - Fork 2
44 lines (39 loc) · 1.19 KB
/
docker-image-ci.yml
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
name: Docker Image CI/CD
on:
push:
branches: ['main']
pull_request:
branches: ['main']
jobs:
build:
runs-on: [self-hosted, linux, x64, frontend]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin
- name: Build and push Docker image
run: |
docker-compose -f docker-compose.build.yml build
docker-compose -f docker-compose.build.yml push
deploy:
runs-on: [self-hosted, linux, x64, frontend]
needs: build
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy
run: |
docker-compose pull
docker-compose up -d
- name: Notify deployment
run: echo "Deployment completed successfully"