mirror of
https://github.com/deadcxap/YandexMusicDiscordBot.git
synced 2026-01-09 07:41:53 +03:00
impr: Docker Workflow (#7)
* automation of creating docker images and sending to dockerhub * badges for main and dev branches, latest-dev tag for dev builds --------- Co-authored-by: deadcxap <dead@cxap.space>
This commit is contained in:
52
.github/workflows/docker-image.yml
vendored
Normal file
52
.github/workflows/docker-image.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
pull_request:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/yandexmusicdiscordbot
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Get short SHA
|
||||
id: vars
|
||||
run: echo "short_sha=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ steps.vars.outputs.short_sha }}
|
||||
|
||||
- name: Set the latest tag for the main branch
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
docker pull $IMAGE_NAME:${{ github.ref_name }}-${{ steps.vars.outputs.short_sha }}
|
||||
docker tag $IMAGE_NAME:${{ github.ref_name }}-${{ steps.vars.outputs.short_sha }} $IMAGE_NAME:latest
|
||||
docker push $IMAGE_NAME:latest
|
||||
|
||||
- name: Set the latest tag for the dev branch
|
||||
if: github.ref == 'refs/heads/dev'
|
||||
run: |
|
||||
docker pull $IMAGE_NAME:${{ github.ref_name }}-${{ steps.vars.outputs.short_sha }}
|
||||
docker tag $IMAGE_NAME:${{ github.ref_name }}-${{ steps.vars.outputs.short_sha }} $IMAGE_NAME:latest-dev
|
||||
docker push $IMAGE_NAME:latest-dev
|
||||
@@ -78,7 +78,8 @@ MONGO_URI='mongodb://localhost:27017/' # Адрес сервера MongoDB
|
||||
|
||||
Запустите бота (`python ./MusicBot/main.py`).
|
||||
|
||||
## Запуск в Docker
|
||||
## Запуск в Docker  
|
||||
|
||||
|
||||
Возможен запуск как из командной строки, так и с помощью docker-compose.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user