Bump actions/checkout from 3 to 4 #86
Workflow file for this run
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
name: build | |
on: | |
push: | |
branches: | |
tags: | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write # for docker push | |
contents: write # for goreleaser | |
steps: | |
- name: set up go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.21" | |
id: go | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: build and test | |
run: | | |
go test -v -timeout=100s -covermode=count -coverprofile=$GITHUB_WORKSPACE/profile.cov_tmp ./... | |
cat $GITHUB_WORKSPACE/profile.cov_tmp > $GITHUB_WORKSPACE/profile.cov | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
- name: run goveralls | |
run: | | |
go install github.com/mattn/goveralls@latest | |
$(go env GOPATH)/bin/goveralls -service="github" -coverprofile=$GITHUB_WORKSPACE/profile.cov | |
env: | |
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: available platforms | |
run: echo ${{ steps.buildx.outputs.platforms }} | |
- name: build and deploy master image to ghcr.io and dockerhub | |
if: ${{ github.ref == 'refs/heads/master' }} | |
env: | |
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} | |
USERNAME: ${{ github.actor }} | |
GITHUB_SHA: ${{ github.sha}} | |
GITHUB_REF: ${{ github.ref}} | |
run: | | |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)" | |
echo GITHUB_REF - $ref | |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${USERNAME} --password-stdin | |
echo ${DOCKER_HUB_TOKEN} | docker login -u paskal --password-stdin | |
docker buildx build --push \ | |
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \ | |
--platform linux/amd64,linux/arm/v7,linux/arm64 \ | |
-t ghcr.io/${USERNAME}/telegram-banhammer:${ref} -t paskal/telegram-banhammer:${ref} . | |
- name: run GoReleaser on tagged release | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
uses: goreleaser/goreleaser-action@v3 | |
with: | |
args: release --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: deploy tagged (latest) to ghcr.io and dockerhub | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
env: | |
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} | |
USERNAME: ${{ github.actor }} | |
GITHUB_SHA: ${{ github.sha}} | |
GITHUB_REF: ${{ github.ref}} | |
run: | | |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)" | |
echo GITHUB_REF - $ref | |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${USERNAME} --password-stdin | |
echo ${DOCKER_HUB_TOKEN} | docker login -u paskal --password-stdin | |
docker buildx build --push \ | |
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \ | |
--platform linux/amd64,linux/arm/v7,linux/arm64 \ | |
-t ghcr.io/${USERNAME}/telegram-banhammer:${ref} -t ghcr.io/${USERNAME}/telegram-banhammer:latest \ | |
-t paskal/telegram-banhammer:${ref} -t paskal/telegram-banhammer:latest . |