Skip to content

fg ep

fg ep #572

Workflow file for this run

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 "radjewwj@gmail.com"
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 "radjewwj@gmail.com"
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 "radjewwj@gmail.com"
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'