mirror of
https://github.com/UiO-Gaming/ShiteMusicBot.git
synced 2026-11-05 13:56:51 +01:00
109 lines
3.3 KiB
YAML
109 lines
3.3 KiB
YAML
name: Test And Build BOT
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
flake8:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
CheckFiles: "bot.py musicbot/"
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Set up Python 3.8
|
|
uses: actions/setup-python@v1
|
|
with:
|
|
python-version: 3.8
|
|
|
|
- name: Lint with flake8
|
|
run: |
|
|
pip install flake8
|
|
flake8 ${CheckFiles}
|
|
|
|
- name: Check with Isort
|
|
run: |
|
|
pip install isort
|
|
isort --check --sp setup.cfg ${CheckFiles}
|
|
|
|
- name: Sort with Isort
|
|
if: failure()
|
|
run: |
|
|
isort --sp setup.cfg ${CheckFiles}
|
|
|
|
- name: Create Pull Request
|
|
if: failure()
|
|
uses: peter-evans/create-pull-request@v2
|
|
with:
|
|
token: ${{ secrets.GH_TOKEN }}
|
|
branch: actions/auto
|
|
commit-message: Changes done by tests
|
|
committer: Roxedus <bot@roxedus.dev>
|
|
title: Linter changed files
|
|
|
|
build-and-push:
|
|
needs: flake8
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name != 'pull_request' && contains(github.ref, 'actions') != 'true'
|
|
env:
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Create VARS
|
|
env:
|
|
_repo: rnorge/music
|
|
_username: roxedus
|
|
_ref: ${{github.ref}}
|
|
id: vars
|
|
run: |
|
|
echo "::set-output name=branch::$(echo ${_ref} | cut -d/ -f3)"
|
|
echo "::set-output name=username::$(echo ${_username} | cut -d/ -f1 | tr '[:upper:]' '[:lower:]')"
|
|
echo "::set-output name=repo::$(echo ${_repo} | tr '[:upper:]' '[:lower:]')"
|
|
|
|
- name: Bump TAG
|
|
if: github.ref == 'refs/heads/master'
|
|
id: tagger
|
|
run: |
|
|
version=$(grep -i bot_version musicbot/cogs/utils/bot_version.py | cut -d" " -f3 | tr -d \")
|
|
a=(${version//./ })
|
|
((a[2]++))
|
|
new_version=$(echo "${a[0]}.${a[1]}.${a[2]}")
|
|
sed -i "s/${version}/${new_version}/g" musicbot/cogs/utils/bot_version.py
|
|
echo "::set-output name=tag::${new_version}"
|
|
|
|
- name: Push changed files, and tags
|
|
if: github.ref == 'refs/heads/master'
|
|
uses: EndBug/add-and-commit@v4
|
|
with:
|
|
add: musicbot/cogs/utils/bot_version.py
|
|
author_name: MarlinBotCode
|
|
message: Bump Version
|
|
tag: v${{ steps.tagger.outputs.tag }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build the Docker image
|
|
env:
|
|
REPO: ${{ steps.vars.outputs.repo }}
|
|
BRANCH: ${{ steps.vars.outputs.branch }}
|
|
run: |
|
|
docker build -t $REPO:$BRANCH -t $REPO:$BRANCH-${{github.sha}} .
|
|
|
|
- name: Master tag
|
|
if: github.ref == 'refs/heads/master'
|
|
env:
|
|
REPO: ${{ steps.vars.outputs.repo }}
|
|
BRANCH: ${{ steps.vars.outputs.branch }}
|
|
run: |
|
|
docker tag $REPO:$BRANCH $REPO:${{ steps.tagger.outputs.tag }}
|
|
|
|
- name: Login to registry
|
|
if: github.event_name != 'pull_request'
|
|
run: echo $DOCKER_PASSWORD | docker login -u ${{ steps.vars.outputs.username }} --password-stdin
|
|
|
|
- name: Pushes the Docker image
|
|
env:
|
|
REPO: ${{ steps.vars.outputs.repo }}
|
|
if: github.event_name != 'pull_request'
|
|
run: docker push -a $REPO
|