-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patholdauth.yaml
More file actions
128 lines (102 loc) · 4.48 KB
/
oldauth.yaml
File metadata and controls
128 lines (102 loc) · 4.48 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Deploy Auth Service
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
env:
REGISTRY: "cr.selcloud.ru/reg4you"
AUTH_SERVER_IMAGE: "auth-server"
AUTH_MIGRATOR_IMAGE: "auth-migrator"
AUTH_SERVER_CONTAINER: "auth-server-container"
AUTH_MIGRATOR_CONTAINER: "auth-migrator-container"
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache-dependency-path: go.sum
- name: Build
run: go build -o ./bin/ -v ./...
- name: Test
run: go test -v ./...
linter:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.61
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
args: --timeout=30m --config=./.golangci.pipeline.yaml
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true
# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true
# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
image-build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Registry
run: docker login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} $REGISTRY
- name: Build and Push Auth Server
run: |
TAG_NAME=$(echo $GITHUB_SHA | head -c7)
docker buildx create --use
docker buildx build --no-cache --push --tag $REGISTRY/$AUTH_SERVER_IMAGE:$TAG_NAME -f ./Dockerfile .
- name: Build and Push Auth Migrator
run: |
TAG_NAME=$(echo $GITHUB_SHA | head -c7)
docker buildx build --no-cache --push --tag $REGISTRY/$AUTH_MIGRATOR_IMAGE:$TAG_NAME -f ./migration.Dockerfile .
deploy-image:
runs-on: ubuntu-latest
needs: image-build-and-push
steps:
- name: Deploy to AWS via SSH action
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSHKEY }}
envs: AUTH_SERVER_IMAGE,AUTH_MIGRATOR_IMAGE,REGISTRY,GITHUB_SHA,AUTH_SERVER_CONTAINER,AUTH_MIGRATOR_CONTAINER
script: |
# Set up variables
TAG_NAME=$(echo $GITHUB_SHA | head -c7)
# Login into Selectel Registry
docker login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} $REGISTRY
# Stop and remove old containers
docker stop $AUTH_SERVER_CONTAINER || true
docker stop $AUTH_MIGRATOR_CONTAINER || true
docker rm $AUTH_SERVER_CONTAINER || true
docker rm $AUTH_MIGRATOR_CONTAINER || true
# Run new containers from new images
docker run -d -p 6000:6000 --name $AUTH_SERVER_CONTAINER -t $REGISTRY/$AUTH_SERVER_IMAGE:$TAG_NAME
docker run -d --name $AUTH_MIGRATOR_CONTAINER -t $REGISTRY/$AUTH_MIGRATOR_IMAGE:$TAG_NAME