-
Notifications
You must be signed in to change notification settings - Fork 2
84 lines (72 loc) · 2.49 KB
/
gradle.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
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
name: Java CI with Gradle
on:
push:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Copy application.properties and gcp cloud storage key into runner
run: |
mkdir -p ./src/main/resources
touch ./src/main/resources/application.properties
echo "${{secrets.APPLICATION_YML}}" > ./src/main/resources/application.properties
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "googlecloudstoragekey.json"
json: ${{ secrets.GCS_JSON_KEY}}
dir: 'src/main/resources/'
- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew build
- name: Docker Login
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }}
- name: Build Docker
run: |
docker build -t ghcr.io/${{ secrets.GHCR_USERNAME }}/ssock:latest .
- name: Push Docker
run: docker push ghcr.io/${{ secrets.GHCR_USERNAME }}/ssock:latest
deploy:
runs-on: ubuntu-latest
permissions: write-all
needs: build
steps:
- uses: actions/checkout@v4
- name: Copy docker-compose into instance
uses: appleboy/scp-action@master
with:
host: ${{ secrets.GCP_HOST }}
username: ${{ secrets.GCP_USERNAME }}
key: ${{ secrets.GCP_PRIVATEKEY }}
source: "./docker-compose.yml"
target: "/home/${{ secrets.GCP_USERNAME }}"
overwrite: true
debug: true
- name: Deploy to Instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.GCP_HOST }}
username: ${{ secrets.GCP_USERNAME }}
key: ${{ secrets.GCP_PRIVATEKEY }}
script: |
echo ${{ secrets.GHCR_PASSWORD }} | sudo docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin
sudo docker pull ghcr.io/${{ secrets.GHCR_USERNAME }}/ssock:latest
sudo docker rm -f $(sudo docker ps -qa) || true
cd /home/${{ secrets.GCP_USERNAME }}
sudo docker-compose up -d
sudo docker image prune -f