ci: release Docker image (#54)

This commit is contained in:
Sculas 2023-01-08 17:57:39 +01:00 committed by GitHub
parent dd083ac77c
commit 00a7de6a93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 82 additions and 1 deletions

72
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,72 @@
name: Release Docker image
on:
push:
branches: [main, dev]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
docker:
strategy:
fail-fast: false
matrix:
arch: [
# [use-cross, target, platform]
[false, x86_64-unknown-linux-gnu, linux/amd64],
[true, aarch64-unknown-linux-gnu, linux/arm64/v8],
]
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v3
- name: Setup Rust toolchain
id: rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.arch[1] }}
override: true
- name: Setup Rust Cache
id: rust-cache
uses: Swatinem/rust-cache@v2
- name: Build
id: rust_build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.arch[0] }}
command: build
args: --release --target ${{ matrix.arch[1] }}
- name: Setup QEMU
id: qemu
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
id: login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Image and Push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: ${{ matrix.arch[2] }}
cache-to: type=gha,mode=max,ignore-error=true
cache-from: type=gha
push: true
tags: revanced/revanced-discord-bot:latest

View File

@ -36,7 +36,7 @@ jobs:
- name: Set up cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
cache-on-failure: "true"
- name: cargo build
uses: actions-rs/cargo@v1

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM gcr.io/distroless/cc
# Discord info
ARG DISCORD_AUTHORIZATION_TOKEN
ENV DISCORD_AUTHORIZATION_TOKEN $DISCORD_AUTHORIZATION_TOKEN
# MongoDB info
ARG MONGODB_URI
ENV MONGODB_URI $MONGODB_URI
COPY ./target/**/release/revanced-discord-bot /
CMD ["/revanced-discord-bot"]