test changed workflow #4
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: Main | |
on: [push, pull_request] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- uses: actions/setup-go@v3 | |
name: go-cache | |
with: | |
go-version: '1.20' | |
check-latest: false | |
cache: true | |
- name: Build | |
env: | |
GOOS: linux | |
CGO_ENABLED: 0 | |
run: go build -v -o gargantua | |
- name: Build Release | |
if: | | |
github.event_name == 'push' && ( | |
startsWith(github.event.ref, 'refs/tags/') | |
|| endsWith(github.event.ref, '/master') | |
) | |
run: | | |
docker buildx create --use | |
docker buildx build --platform linux/amd64,linux/arm64 -t seboknt/gargantua:${GIT_COMMIT_SHORT_HASH:-dev} -f cicd/Dockerfile . | |
- name: Compute Docker Tag | |
if: | | |
github.event_name == 'push' && ( | |
startsWith(github.event.ref, 'refs/tags/') | |
|| endsWith(github.event.ref, '/master') | |
) | |
id: compute_docker_tag | |
run: | | |
tag=${GITHUB_REF#refs/tags/} | |
branch=${GITHUB_REF#refs/heads/} | |
if [ "$tag" != "$GITHUB_REF" ]; then | |
tag=$(echo "$tag" | sed -e 's/[^a-zA-Z0-9\-\.]/-/g') | |
echo ::set-output name=DOCKER_TAG::${tag} | |
elif [ "$branch" != "$GITHUB_REF" ]; then | |
branch=$(echo "$branch" | sed -e 's/[^a-zA-Z0-9\-\.]/-/g') | |
echo ::set-output name=DOCKER_TAG::${branch} | |
else | |
echo "unable to determine docker tag" >&2 | |
exit 1 | |
fi | |
- name: Docker Login | |
if: | | |
github.event_name == 'push' && ( | |
startsWith(github.event.ref, 'refs/tags/') | |
|| endsWith(github.event.ref, '/master') | |
) | |
run: | | |
echo "${{ secrets.DOCKER_HUB_PASSWORD }}" \ | |
| docker login -u "${{ secrets.DOCKER_HUB_USER }}" --password-stdin | |
- name: Docker Tag | |
if: | | |
github.event_name == 'push' && ( | |
startsWith(github.event.ref, 'refs/tags/') | |
|| endsWith(github.event.ref, '/master') | |
) | |
run: | | |
docker buildx build --push --platform linux/amd64,linux/arm64 \ | |
-t seboknt/gargantua:${{ steps.compute_docker_tag.outputs.DOCKER_TAG }} \ | |
-f cicd/Dockerfile . | |
- name: Docker Tag Latest | |
if: | | |
github.event_name == 'push' && ( | |
startsWith(github.event.ref, 'refs/tags/') | |
) | |
run: | | |
docker buildx build --push --platform linux/amd64,linux/arm64 \ | |
-t seboknt/gargantua:latest \ | |
-f cicd/Dockerfile . |