-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (94 loc) · 3.65 KB
/
google-ce.yaml
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
99
100
101
102
103
104
name: Push-to-Google-CE
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
jobs:
build:
name: Checkout repository
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
publish:
permissions:
contents: 'read'
id-token: 'write'
needs: build
name: Publish image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Authenticate with Google
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.FB_PROJECT_ID }}
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.FB_PROJECT_ID }}
- name: Build Docker image
run: |
gcloud auth configure-docker ${{vars.REGION}}-docker.pkg.dev
IMAGE="${{vars.REGION}}-docker.pkg.dev/${{secrets.FB_PROJECT_ID}}/colndir-botting/${{ secrets.DOCKER_IMAGE_NAME_STAGING }}:latest"
docker buildx build -t $IMAGE \
--build-arg "TOKEN=${{ secrets.TOKEN }}" \
--build-arg "EMOJI_SERVER_ID=${{ secrets.EMOJI_SERVER_ID }}" \
--build-arg "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" \
--build-arg "FB_PROJECT_ID=${{ secrets.FB_PROJECT_ID }}" \
--build-arg "FB_PRIVATE_KEY=${{ secrets.FB_PRIVATE_KEY }}" \
--build-arg "FB_CLIENT_EMAIL=${{ secrets.FB_CLIENT_EMAIL }}" \
--build-arg "GOOGLEAPI_PRIVATE_KEY=${{ secrets.GOOGLEAPI_PRIVATE_KEY }}" \
--build-arg "GOOGLEAPI_CLIENT_EMAIL=${{ secrets.GOOGLEAPI_CLIENT_EMAIL }}" \
--build-arg "CLOUDRUN_PORT=${{ secrets.CLOUDRUN_PORT }}" .
docker push $IMAGE
# deploy:
# needs: publish
# name: Deploy to Google Compute Engine on master branch push
# runs-on: ubuntu-latest
# steps:
# - name: Set up Node.js
# uses: actions/setup-node@v3
# with:
# node-version: ${{ env.NODE_VERSION }}
# cache: 'npm'
# - name: Compile TypeScript into JavaScript
# run: |
# cd out
# tsc
# - name: Copy files via SCP
# uses: appleboy/scp-action@master
# with:
# host: ${{ secrets.COLNDIR_HOST_IP }}
# username: ${{ secrets.COLNDIR_HOST_USERNAME }}
# key: ${{ secrets.COLNDIR_HOST_PRIVATE_KEY }}
# port: 22
# source: "out/*"
# target: ${{ secrets.TARGET_DIR }}
# rm: true
# overwrite: true
# - name: Run Commands on the Google Compute Engine
# uses: appleboy/ssh-action@master
# env:
# TARGET_DIR: ${{ secrets.TARGET_DIR }}
# TOKEN: ${{secrets.TOKEN}}
# FB_PROJECT_ID: ${{secrets.FB_PROJECT_ID}}
# FB_PRIVATE_KEY: ${{secrets.FB_PRIVATE_KEY}}
# FB_CLIENT_EMAIL: ${{secrets.FB_CLIENT_EMAIL}}
# OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# GOOGLEAPI_PRIVATE_KEY: ${{secrets.GOOGLEAPI_PRIVATE_KEY}}
# GOOGLEAPI_CLIENT_EMAIL: ${{secrets.GOOGLEAPI_CLIENT_EMAIL}}
# with:
# host: ${{ secrets.COLNDIR_HOST_IP }}
# username: ${{ secrets.COLNDIR_HOST_USERNAME }}
# key: ${{ secrets.COLNDIR_HOST_PRIVATE_KEY }}
# envs: TARGET_DIR,TOKEN,FB_PROJECT_ID,FB_PRIVATE_KEY,FB_CLIENT_EMAIL,OPENAI_API_KEY,GOOGLEAPI_PRIVATE_KEY,GOOGLEAPI_CLIENT_EMAIL
# script: |
# echo $TOKEN > token.txt
# cd $TARGET_DIR
# cd out
# npm run host