name: Build and Publish on: push: branches: [main] tags: ["v*"] env: REGISTRY: git.atlashorizon.net IMAGE_NAME: ${{ github.repository }} jobs: build-and-publish: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 # ACTION_TOKEN is a personal access token with package read/write scope, # stored as a runner secret (the automatic GITEA_TOKEN doesn't work for # registry auth on this instance). - name: Log in to Gitea container registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} password: ${{ secrets.ACTION_TOKEN }} - name: Extract image metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=raw,value=latest,enable={{is_default_branch}} type=semver,pattern={{version}} type=sha labels: | org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} - name: Build and push image uses: docker/build-push-action@v6 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} # Links the container package to this repository so it shows up on the # repo's Packages tab. Returns an error if it's already linked, which is # fine — hence the fallback message instead of failing the job. - name: Link package to repository run: | curl -sf -X POST \ -H "Authorization: token ${{ secrets.ACTION_TOKEN }}" \ "${{ github.server_url }}/api/v1/packages/${{ github.repository_owner }}/container/${{ github.event.repository.name }}/-/link/${{ github.event.repository.name }}" \ && echo "Package linked to repository" \ || echo "Link skipped (already linked, or token lacks permission)"