Skip to content

Trigger gotify/build on update #414

Trigger gotify/build on update

Trigger gotify/build on update #414

Workflow file for this run

name: build
on: [push, pull_request]
permissions:
actions: write
jobs:
check-build-container:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create build container if not present
run: |
GO_VERSION=$(cat GO_VERSION)
if docker pull gotify/build:$GO_VERSION-linux-amd64; then
echo "Image already present"
else
echo "Image not present, triggering build"
gh workflow -R gotify/build run Tag -F "go_version=$GO_VERSION" || exit 1
echo "Waiting for image to be built"
gh run list -R gotify/build --workflow=Build --json headSha,conclusion,event,createdAt,databaseId -q '[.[] | select (.event == "workflow_dispatch")][0] | .databaseId' > run_id
TIMEOUT=$((60*10))
echo "Waiting for run to finish"
while [ $TIMEOUT -gt 0 ]; do
if gh run view -R gotify/build $(cat run_id) --json conclusion -q '.conclusion' | grep -q success; then
echo "Image built"
break
fi
if gh run view -R gotify/build $(cat run_id) --json conclusion -q '.conclusion' | grep -q failure; then
echo "Image build failed"
exit 1
fi
sleep 10
TIMEOUT=$((TIMEOUT-10))
done
if [ $TIMEOUT -le 0 ]; then
echo "Timeout reached"
exit 1
fi
fi
gotify:
runs-on: ubuntu-latest
needs: check-build-container
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.22.x
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/checkout@v4
- run: (cd ui && yarn)
- run: make build-js
- uses: golangci/golangci-lint-action@v5
with:
version: v1.55
args: --timeout=5m
skip-cache: true
- run: go mod download
- run: make download-tools
- run: make test
- run: make check-ci
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- if: startsWith(github.ref, 'refs/tags/v')
run: |
export LD_FLAGS="-w -s -X main.Version=$VERSION -X main.BuildDate=$(date "+%F-%T") -X main.Commit=$(git rev-parse --verify HEAD) -X main.Mode=prod"
make build
sudo chown -R $UID build
make package-zip
ls -lath build
make build-docker
docker image ls
echo "$DOCKER_PASS" | docker login --username "$DOCKER_USER" --password-stdin
echo "$DOCKER_GHCR_PASS" | docker login ghcr.io --username "$DOCKER_GHCR_USER" --password-stdin
docker push --all-tags gotify/server
docker push --all-tags gotify/server-arm7
docker push --all-tags gotify/server-arm64
docker push --all-tags gotify/server-riscv64
docker push --all-tags ghcr.io/gotify/server
docker push --all-tags ghcr.io/gotify/server-arm7
docker push --all-tags ghcr.io/gotify/server-arm64
docker push --all-tags ghcr.io/gotify/server-riscv64
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
DOCKER_GHCR_USER: ${{ secrets.DOCKER_GHCR_USER }}
DOCKER_GHCR_PASS: ${{ secrets.DOCKER_GHCR_PASS }}
- if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/*.zip
tag: ${{ github.ref }}
overwrite: true
file_glob: true