Skip to content

add docker login

add docker login #20

Workflow file for this run

name: Build
on:
push:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: gotify-build-lock
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Sanity check
run: |
GO_VERSION=$(cat GO_VERSION)
MATCHES=$(curl -fsSL 'https://go.dev/dl/?mode=json&include=all' | jq --arg GO_VERSION "$GO_VERSION" -r 'map(select(.version == "go\($GO_VERSION)")) | length')
if [ "$MATCHES" -ne 1 ]; then
echo "Invalid Go version: $GO_VERSION, found $MATCHES matches"
exit 1
fi
- name: Build
run: make build
- name: Login to Docker
if: ${{ !startsWith(github.ref, 'refs/tags/v') && github.ref == 'refs/heads/master' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Push and tag
# push if we are not already tagged, the workflow is triggered by a manual go_version input or we are on master
if: ${{ !startsWith(github.ref, 'refs/tags/v') && github.ref == 'refs/heads/master' }}
run: |
GO_VERSION=$(cat GO_VERSION)
if git tag --list "v${GO_VERSION}" | grep -q "v${GO_VERSION}"; then
echo "Tag v${GO_VERSION} already exists"
exit 1
fi
if ! make push; then
echo "Failed to push tags"
exit 1
fi
git tag "v${GO_VERSION}" -m "Bump to Go $GO_VERSION"
git push origin --tags