-
Notifications
You must be signed in to change notification settings - Fork 4
67 lines (57 loc) · 1.86 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
67
name: Build binaries
on:
push:
branches:
- '*'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.16.0'
- name: Extract branch name
shell: bash
run: |
OBJECT_SUFFIX=''
DOCKER_TAG="latest"
if [[ "${GITHUB_REF_NAME}" != "main" ]]; then
OBJECT_SUFFIX=".${GITHUB_REF_NAME}"
DOCKER_TAG="${GITHUB_REF_NAME}"
fi
echo "object_suffix=${OBJECT_SUFFIX}" >> $GITHUB_ENV
echo "docker_tag=${DOCKER_TAG}" >> $GITHUB_ENV
id: extract_branch
- name: Run Go builds
run: |
OBJECT_SUFFIX="${{ env.object_suffix }}"
mkdir output/
go build -o "output/modem-stats${OBJECT_SUFFIX}.x86" main.go
GOARCH=arm GOARM=5 go build -o "output/modem-stats${OBJECT_SUFFIX}.arm5" main.go
GOOS=darwin GOARCH=arm64 go build -o "output/modem-stats${OBJECT_SUFFIX}.macos-arm64" main.go
- name: Push binaries to B2
uses: jakejarvis/s3-sync-action@master
env:
AWS_S3_BUCKET: modem-stats
AWS_ACCESS_KEY_ID: ${{ secrets.B2_APPKEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.B2_APPKEY }}
SOURCE_DIR: 'output'
AWS_S3_ENDPOINT: 'https://s3.us-west-000.backblazeb2.com/'
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
tags: msh100/modem-stats:${{ env.docker_tag }}
build-args: |
OBJECT_SUFFIX=${{ env.object_suffix }}
context: .