mirror of
https://github.com/deadcxap/YandexMusicDiscordBot.git
synced 2026-01-09 07:31:54 +03:00
automation of creating docker images and sending to dockerhub
This commit is contained in:
45
.github/workflows/docker-image.yml
vendored
Normal file
45
.github/workflows/docker-image.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
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
|
||||
@@ -78,7 +78,7 @@ MONGO_URI='mongodb://localhost:27017/' # Адрес сервера MongoDB
|
||||
|
||||
Запустите бота (`python ./MusicBot/main.py`).
|
||||
|
||||
## Запуск в Docker
|
||||
## Запуск в Docker 
|
||||
|
||||
Возможен запуск как из командной строки, так и с помощью docker-compose.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user