Repository navigation
98 lines (84 loc) · 2.52 KB
/
Copy pathdeployment-odds-cloud.yml
File metadata and controls
98 lines (84 loc) · 2.52 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
on:
push:
branches: ["main"]
name: CI/CD Project worklogAPI Develop (ODDS Cloud)
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_TAG: dev-odds-cloud
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Run tests
run: make test
build:
name: Build
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build, tag, and push image to GHCR
id: build-image
run: |
IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
docker build -t "$IMAGE" .
docker push "$IMAGE"
deploy:
name: Deploy
needs: build
runs-on: self-hosted
permissions:
contents: read
packages: read
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull docker image
id: pull-image
run: |
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
- name: Checkout for get docker compose file
uses: actions/checkout@v4
- name: copy docker compose file via ssh password
uses: appleboy/scp-action@v1.0.0
with:
host: ${{ vars.ODDS_CLOUD_DEV_HOST }}
username: ubuntu
key: ${{ secrets.ODDS_CLOUD_DEV_PRIVATE_KEY}}
source: "deployment/dev/docker-compose.yaml"
target: "/home/ubuntu/worklog"
strip_components: 2
- name: SSH Shell Command
uses: fifsky/ssh-action@master
with:
command: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
cd /home/ubuntu/worklog
docker compose pull
docker compose down
docker compose up -d
host: ${{ vars.ODDS_CLOUD_DEV_HOST }}
user: ubuntu
key: ${{ secrets.ODDS_CLOUD_DEV_PRIVATE_KEY}}