Skip to content

Build Gitea

Build Gitea #14

name: Build Gitea
on:
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
outputs:
version: "${{ steps.check.outputs.result }}"
steps:
- name: Compare repo and image version
shell: bash
run: |
new="$(curl -sL https://api.github.com/repos/go-gitea/gitea/releases/latest | jq -r '.tag_name | values | sub("^v";"")')"
if [ -n "$new" ]; then
old="$(curl -sL https://hub.docker.com/v2/repositories/stelas/gitea-arm/tags/${new} | jq -r '.name | values')"
if [ -z "$old" ]; then
echo "version=$new" >> $GITHUB_ENV
fi
fi
- name: Return new version or cancel build
uses: actions/github-script@v6
id: check
with:
script: |
const { owner, repo } = context.repo
if (${{ env.version == null }}) {
const run_id = "${{ github.run_id }}";
await github.actions.cancelWorkflowRun({ owner, repo, run_id });
return 'false'
} else {
return "${{ env.version }}"
}
result-encoding: string
build:
needs: check
if: needs.check.outputs.version != 'false'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
with:
repository: go-gitea/gitea
ref: "v${{ needs.check.outputs.version }}"
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Docker login
uses: docker/login-action@v3
with:
username: "${{ secrets.DOCKERHUB_USERNAME }}"
password: "${{ secrets.DOCKERHUB_PASSWORD }}"
- name: Build and push images
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm/v7
push: true
tags: "jackadam/gitea:${{ needs.check.outputs.version }},jackadam/gitea:latest"