-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
96 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
FROM alpine:latest | ||
FROM --platform=$TARGETPLATFORM alpine:latest | ||
MAINTAINER SJ Zhou <[email protected]> | ||
|
||
WORKDIR /app | ||
COPY morooi-telegram-bot-go /app/morooi-telegram-bot-go | ||
COPY bot /app/bot | ||
|
||
# 设置时区 | ||
ENV TZ=Asia/Shanghai | ||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | ||
|
||
ENTRYPOINT ["/app/morooi-telegram-bot-go"] | ||
ENTRYPOINT ["/app/bot"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Docker Build & Publish | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
ASSET_NAME: bot | ||
IMAGE_NAME: morooi/morooi-telegram-bot-go | ||
|
||
jobs: | ||
build-and-publish: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- goos: linux | ||
goarch: amd64 | ||
platform: linux/amd64 | ||
- goos: linux | ||
goarch: arm64 | ||
platform: linux/arm64 | ||
- goos: darwin | ||
goarch: amd64 | ||
platform: darwin/amd64 | ||
- goos: darwin | ||
goarch: arm64 | ||
platform: darwin/arm64 | ||
|
||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
CGO_ENABLED: 0 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
check-latest: true | ||
|
||
- name: Get project dependencies | ||
run: go mod download | ||
|
||
- name: Build Code | ||
run: go build -v -o ${{ env.ASSET_NAME }} | ||
|
||
- name: Upload files to Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.ASSET_NAME }} | ||
path: ${{ env.ASSET_NAME }} | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Copy Dockerfile | ||
run: copy .github/workflows/Dockerfile ./ | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
platforms: ${{ matrix.platform }} | ||
tags: ${{ env.IMAGE_NAME }}:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters