Skip to content

actions

actions #2

Workflow file for this run

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