-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (53 loc) · 1.76 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
env:
CGO_ENABLED: 0
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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: |
GOOS=linux GOARCH=amd64 go build -v -o asset/${{ env.ASSET_NAME }}-linux-amd64 -ldflags "-s -w -buildid="
GOOS=linux GOARCH=arm64 go build -v -o asset/${{ env.ASSET_NAME }}-linux-arm64 -ldflags "-s -w -buildid="
GOOS=darwin GOARCH=amd64 go build -v -o asset/${{ env.ASSET_NAME }}-darwin-amd64 -ldflags "-s -w -buildid="
GOOS=darwin GOARCH=arm64 go build -v -o asset/${{ env.ASSET_NAME }}-darwin-arm64 -ldflags "-s -w -buildid="
- name: Upload files to Artifacts
uses: actions/upload-artifact@v3
with:
name: bot
path: asset/*
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Copy Dockerfile
run: cp .github/workflows/Dockerfile ./
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ env.IMAGE_NAME }}:latest