mirror of
https://github.com/UiO-Gaming/ShiteMusicBot.git
synced 2026-11-05 13:56:51 +01:00
3 files changed
+58
-96
No files matched your search
+53
-19
@@ -8,10 +8,12 @@ jobs:
|
||||
CheckFiles: "bot.py cogs/"
|
||||
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
|
||||
@@ -21,10 +23,12 @@ jobs:
|
||||
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
|
||||
@@ -38,36 +42,66 @@ jobs:
|
||||
build-and-push:
|
||||
needs: flake8
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'pull_request' && contains(github.ref, 'actions') != 'true' && ! contains(toJSON(github.event.commits.*.message), '[ci skip]')
|
||||
env:
|
||||
repo: rnorge/music
|
||||
ref: ${{github.ref}}
|
||||
DOCKER_USERNAME: roxedus
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build the Docker image
|
||||
|
||||
- name: Create VARS
|
||||
env:
|
||||
_repo: rnorge/music
|
||||
_ref: ${{github.ref}}
|
||||
id: vars
|
||||
run: |
|
||||
branch="${ref##*/}"
|
||||
docker build -t $repo:$branch -t $repo:$branch-${{github.sha}} .
|
||||
echo "::set-output name=branch::$(echo ${_ref} | cut -d/ -f3)"
|
||||
echo "::set-output name=username::roxedus"
|
||||
echo "::set-output name=repo::rnorge/music"
|
||||
|
||||
- name: Bump TAG
|
||||
if: github.ref == 'refs/heads/master'
|
||||
id: tagger
|
||||
run: |
|
||||
version=$(grep -i bot_version 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" 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: cogs/utils/bot_version.py
|
||||
author_name: MarlinBotCode
|
||||
message: Bump Version
|
||||
tag: ${{ steps.vars.tagger.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: |
|
||||
branch="${ref##*/}"
|
||||
bot_ver=$(grep -i bot_version cogs/utils/bot_version.py | cut -d" " -f3 | tr -d \")
|
||||
docker tag $repo:$branch $repo:$bot_ver
|
||||
|
||||
- name: Bump version and push tag
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: mathieudutour/github-tag-action@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
docker tag $REPO:$BRANCH $REPO:${{ steps.vars.tagger.tag }}
|
||||
|
||||
- name: Login to registry
|
||||
if: github.event.pull_request == false
|
||||
run: echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
|
||||
if: github.event_name != 'pull_request'
|
||||
run: echo $DOCKER_PASSWORD | docker login -u ${{ steps.vars.outputs.username }} --password-stdin
|
||||
|
||||
- name: Pushes the Docker image
|
||||
if: github.event.pull_request == false
|
||||
run: docker push $repo
|
||||
env:
|
||||
REPO: ${{ steps.vars.outputs.repo }}
|
||||
if: github.event_name != 'pull_request'
|
||||
run: docker push $REPO
|
||||
Vendored
-71
@@ -1,71 +0,0 @@
|
||||
pipeline {
|
||||
agent none
|
||||
environment {
|
||||
GIT_REPO = 'Ev-1/ShiteMusicBot'
|
||||
DOCKER_REPO = 'rnorge/music'
|
||||
TAG=""
|
||||
FLAKE_FILES = "bot.py cogs/*.py cogs/utils/*.py"
|
||||
}
|
||||
stages {
|
||||
stage('Flake8') {
|
||||
agent { label 'amd64'}
|
||||
steps {
|
||||
sh """
|
||||
python3.7 -m venv venv && venv/bin/pip install flake8 && venv/bin/python -m flake8 --max-line-length 120 ${FLAKE_FILES}
|
||||
rm -rf venv/
|
||||
"""
|
||||
script {
|
||||
TAG = sh(returnStdout: true, script: 'grep -i bot_version cogs/utils/bot_version.py | cut -d" " -f3 | tr -d \\"').trim()
|
||||
SBranch = sh(returnStdout: true, script: 'echo ${GIT_BRANCH} | sed "s#/#_#"').trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Docker Builds') {
|
||||
parallel {
|
||||
stage('branch') {
|
||||
agent { label 'amd64'}
|
||||
when {
|
||||
not {
|
||||
changeRequest()
|
||||
}
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
if (BRANCH_NAME == 'master') {
|
||||
def image = docker.build("${DOCKER_REPO}:${TAG}-amd64")
|
||||
image.push("${TAG}-amd64")
|
||||
image.push("latest-amd64")
|
||||
}
|
||||
else {
|
||||
def image = docker.build("${DOCKER_REPO}:${SBranch}-amd64")
|
||||
image.push()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('pr') {
|
||||
agent { label 'amd64'}
|
||||
when { changeRequest() }
|
||||
steps {
|
||||
script {
|
||||
def image = docker.build("${DOCKER_REPO}:PR_$GIT_BRANCH-amd64")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('GitHub Release') {
|
||||
when { branch 'master' }
|
||||
agent { label 'amd64'}
|
||||
steps {
|
||||
withCredentials([usernameColonPassword(credentialsId: 'RoxBot-Dev Github', variable: 'GitCred')]) {
|
||||
sh """
|
||||
git remote set-url origin "https://${GitCred}@github.com/${GIT_REPO}.git"
|
||||
git tag ${TAG}
|
||||
git push --tags
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -88,9 +88,6 @@ class Music(commands.Cog):
|
||||
await ctx.send(embed=embed)
|
||||
else:
|
||||
track = results['tracks'][0]
|
||||
thumbnail_url = await thumbnailer.ThumbNailer.identify(
|
||||
self, track['info']['identifier'], track['info']['uri'])
|
||||
track = lavalink.models.AudioTrack(track, ctx.author.id, thumbnail_url=thumbnail_url)
|
||||
await self.enqueue(ctx, track, embed)
|
||||
embed = ctx.localizer.format_embed(embed)
|
||||
await ctx.send(embed=embed)
|
||||
@@ -768,9 +765,6 @@ class Music(commands.Cog):
|
||||
async def enqueue(self, ctx, track, embed):
|
||||
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
||||
|
||||
if isinstance(track, dict):
|
||||
track = lavalink.models.AudioTrack(track, ctx.author.id)
|
||||
|
||||
maxlength = self.max_track_length(ctx.guild, player)
|
||||
if maxlength and track['info']['length'] > maxlength:
|
||||
embed.description = ctx.localizer.format_str("{enqueue.toolong}",
|
||||
@@ -778,6 +772,11 @@ class Music(commands.Cog):
|
||||
_max=timeformatter.format_ms(maxlength))
|
||||
return
|
||||
|
||||
if isinstance(track, dict):
|
||||
thumbnail_url = await thumbnailer.ThumbNailer.identify(
|
||||
self, track['info']['identifier'], track['info']['uri'])
|
||||
track = lavalink.models.AudioTrack(track, ctx.author.id, thumbnail_url=thumbnail_url)
|
||||
|
||||
track, pos_global, pos_local = player.add(requester=ctx.author.id, track=track)
|
||||
|
||||
if player.current is not None:
|
||||
|
||||
Reference in new issue
Block a user