-
-
Notifications
You must be signed in to change notification settings - Fork 12
232 lines (214 loc) · 9.74 KB
/
dockerpush.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Docker
on:
push:
# Publish `main` as Docker `latest` image.
branches:
- main
# Publish `v1.2.3` tags as releases.
tags:
- v*
pull_request:
env:
# TODO: Change variable to your image's name.
IMAGE_NAME: cfb-api
jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
# test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v1
# - name: Run tests
# run: |
# npm install
# npm test
# env:
# HOST: ${{ secrets.DATABASE_HOST }}
# DATABASE_USER: ${{ secrets.DATABASE_USER }}
# DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
# DATABASE_PORT: ${{ secrets.DATABASE_PORT }}
# DATABASE: ${{ secrets.DATABASE }}
# Push image to GitHub Package Registry.
# See also https://docs.docker.com/docker-hub/builds/
push:
# Ensure test job passes before pushing image.
# needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Build image
run: docker build . --file Dockerfile --tag image
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/cfbd/cfb-api/$IMAGE_NAME
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
deploy:
needs: push
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /docker/cfb
docker pull docker.pkg.github.com/cfbd/cfb-api/cfb-api
docker-compose up -d
publish-js:
needs: deploy
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Install dependencies
run: |
sudo apt install wget -y
sudo apt install unzip -y
sudo apt install jq -y
sudo apt install curl -y
- name: Git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "BlueSCar"
- name: Generate library
id: lib
run: |
code=$(curl -X POST -H "content-type:application/json" -d '{"swaggerUrl": "https://api.collegefootballdata.com/api-docs.json", "options": {"projectName": "cfb.js", "moduleName": "cfb", "licenseName": "MIT", "usePromises": "true", "useES6": "false"}}' https://generator.swagger.io/api/gen/clients/javascript | jq '. | .code')
code=${code%\"}
code=${code#\"}
echo "::set-output name=code::$code"
- name: Extract and push
continue-on-error: true
run: |
echo extracting codebase...
wget https://generator.swagger.io/api/gen/download/${{ steps.lib.outputs.code }}
unzip ${{ steps.lib.outputs.code }}
echo cloning codebase...
git clone https://BlueSCar:${{ secrets.ACCESS_TOKEN }}@github.com/cfbd/cfb.js.git
sudo yes | cp -a ./javascript-client/. cfb.js
cd cfb.js
echo installing json module...
sudo npm i -g json
echo updating package.config...
json -I -f package.json -e 'this.keywords=["football","cfb","ncaaf","data","statistics"]'
json -I -f package.json -e 'this.author="BlueSCar"'
json -I -f package.json -e 'this.repository={"type": "git", "url": "https://github.com/cfbd/cfb.js.git"}'
sed -i '103,104d' README.md
sed -i '102s/.*/ApiKeyAuth.apiKey = "Bearer YOUR_API_KEY";/' README.md
sed -i '26,59d' README.md
echo "Adding changes..."
git add .
echo "Committing changes ..."
git commit -am "${{ github.event.commits[0].message }}"
echo "Pushing to remote..."
git push origin master 2>&1 | grep -v 'To https'
publish-csharp:
needs: deploy
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Install dependencies
run: |
sudo apt install wget -y
sudo apt install unzip -y
sudo apt install jq -y
sudo apt install curl -y
- name: Git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "BlueSCar"
- name: Generate library
id: lib
run: |
code=$(curl -X POST -H "content-type:application/json" -d '{"swaggerUrl": "https://api.collegefootballdata.com/api-docs.json", "options": { "packageName": "CFBSharp", "targetFramework": "v5.0", "returnICollection": "true", "netCoreProjectFile": "true", "validatable": "true"}}' https://generator.swagger.io/api/gen/clients/csharp | jq '. | .code')
code=${code%\"}
code=${code#\"}
echo "::set-output name=code::$code"
- name: Extract and push
run: |
echo Extracting new codebase...
wget https://generator.swagger.io/api/gen/download/${{ steps.lib.outputs.code }}
unzip ${{ steps.lib.outputs.code }}
echo cloning existing codebase....
git clone https://BlueSCar:${{ secrets.ACCESS_TOKEN }}@github.com/cfbd/CFBSharp.git
echo copying changes....
sudo yes | cp -a ./csharp-client/. CFBSharp
cd CFBSharp
git add .
echo Updating files
sed -i '26s/.*/Add the package using the dotnet CLI:\r\n```powershell\r\ndotnet add package CFBSharp\r\n```/' README.md
sed -i '31s/.*/Then use the relevant namespaces:/' README.md
match=$(grep -E 'API version: [0-9]+\.[0-9]+\.[0-9]+' README.md)
api_version=$(echo $match | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
sed -i '8s/.*/- SDK version: '"$api_version"'/' README.md
sed -i '56d' README.md
sed -i '56s/.*/ Configuration.Default.ApiKeyPrefix.Add("Authorization", "Bearer");/' README.md
sed -i '17s/.*/ <Version>'"$api_version"'<\/Version>/' ./src/CFBSharp/CFBSharp.csproj
sed -i '4s/.*/ <TargetFramework>netstandard2.1<\/TargetFramework>/' ./src/CFBSharp/CFBSharp.csproj
sed -i '17a\ \ \ \ <RepositoryUrl>https://github.com/cfbd/CFBSharp.git<\/RepositoryUrl>' ./src/CFBSharp/CFBSharp.csproj
sed -i '18a\ \ \ \ <RepositoryType>git<\/RepositoryType>' ./src/CFBSharp/CFBSharp.csproj
sed -i '19a\ \ \ \ <PackageIconUrl>https://cfbd-public.s3.us-east-2.amazonaws.com/package_logo.png<\/PackageIconUrl>' ./src/CFBSharp/CFBSharp.csproj
sed -i '20a\ \ \ \ <PackageLicenseExpression>MIT<\/PackageLicenseExpression>' ./src/CFBSharp/CFBSharp.csproj
sed -i '21a\ \ \ \ <PackageTags>CFB;NCAAF;NCAA;football<\/PackageTags>' ./src/CFBSharp/CFBSharp.csproj
echo "Committing changes ..."
git commit -am "${{ github.event.commits[0].message }}"
echo "Pushing to remote..."
git push origin master 2>&1 | grep -v 'To https'
publish-python:
needs: deploy
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Install dependencies
run: |
sudo apt install wget -y
sudo apt install unzip -y
sudo apt install jq -y
sudo apt install curl -y
- name: Git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "BlueSCar"
- name: Generate library
id: lib
run: |
api_version=$(curl https://api.collegefootballdata.com/api-docs.json | jq .info.version)
code=$(curl -X POST -H "content-type:application/json" -d '{"swaggerUrl": "https://api.collegefootballdata.com/api-docs.json", "options": { "packageName": "cfbd", "projectName": "cfbd", "packageUrl": "https://github.com/CFBD/cfbd-python", "packageVersion": '"${api_version}"'}}' https://generator.swagger.io/api/gen/clients/python | jq '. | .code')
code=${code%\"}
code=${code#\"}
echo "::set-output name=code::$code"
- name: Extract and push
run: |
echo Extracting new codebase...
wget https://generator.swagger.io/api/gen/download/${{ steps.lib.outputs.code }}
unzip ${{ steps.lib.outputs.code }}
echo cloning existing codebase....
git clone https://BlueSCar:${{ secrets.ACCESS_TOKEN }}@github.com/cfbd/cfbd-python.git
echo copying changes....
sudo yes | cp -a ./python-client/. cfbd-python
cd cfbd-python
git add .
echo Updating files
sed -i '16,17d' README.md
sed -i '55d' README.md
sed -i '55s/# //' README.md
sed -i -e 's/git+https:\/\/github.com\/\/.git/cfbd/g' README.md
echo "Committing changes ..."
git commit -am "${{ github.event.commits[0].message }}"
echo "Pushing to remote..."
git push origin master 2>&1 | grep -v 'To https'