ci: update build-publish workflow for multi-branch and tag support #8

Merged
daniel merged 1 commits from ci/update-workflow into main 2026-04-09 23:10:41 +00:00
Collaborator

Summary

Updates .github/workflows/build-publish.yaml per issue #7:

  • Every branch/PR: builds the Docker image but does not push
  • main branch push: pushes main, latest, and <sha> tags
  • Version tag push (e.g. v1.0.3): pushes <tag>, latest, and <sha> tags
  • Uses Gitea Actions context vars (gitea.ref, gitea.sha, gitea.ref_name, gitea.repository)

Image tags produced

Trigger Tags
main branch git.danhenry.dev/daniel/email-classifier:{main,latest,<sha>}
v*.*.* tag git.danhenry.dev/daniel/email-classifier:{<tag>,latest,<sha>}
Other branches / PRs Build only, no push

Closes #7

## Summary Updates `.github/workflows/build-publish.yaml` per issue #7: - **Every branch/PR**: builds the Docker image but does **not** push - **main branch push**: pushes `main`, `latest`, and `<sha>` tags - **Version tag push** (e.g. `v1.0.3`): pushes `<tag>`, `latest`, and `<sha>` tags - Uses Gitea Actions context vars (`gitea.ref`, `gitea.sha`, `gitea.ref_name`, `gitea.repository`) ## Image tags produced | Trigger | Tags | |---|---| | `main` branch | `git.danhenry.dev/daniel/email-classifier:{main,latest,<sha>}` | | `v*.*.*` tag | `git.danhenry.dev/daniel/email-classifier:{<tag>,latest,<sha>}` | | Other branches / PRs | Build only, no push | Closes #7
Owner

The PR didn't build

Build (no push — all branches and PRs)
-493269h45m56s
  ❌  Error in if-expression: "if: github.event_name != 'push' || (github.event_name == 'push' && !gitea.ref.startsWith('refs/tags/v') && gitea.ref != 'refs/heads/main')" (Failed to parse: unexpected token "(" while parsing closing ')' of nested expression (...). expecting ")")
The PR didn't build ``` Build (no push — all branches and PRs) -493269h45m56s ❌ Error in if-expression: "if: github.event_name != 'push' || (github.event_name == 'push' && !gitea.ref.startsWith('refs/tags/v') && gitea.ref != 'refs/heads/main')" (Failed to parse: unexpected token "(" while parsing closing ')' of nested expression (...). expecting ")") ```
lennie-s added 1 commit 2026-04-09 23:05:36 +00:00
ci: fix if-expression syntax and restructure into separate jobs
All checks were successful
Build and Publish Docker Image / build-only (push) Successful in 3m23s
Build and Publish Docker Image / build-and-push-main (push) Has been skipped
Build and Publish Docker Image / build-and-push-tag (push) Has been skipped
Build and Publish Docker Image / build-only (pull_request) Successful in 2m7s
Build and Publish Docker Image / build-and-push-main (pull_request) Has been skipped
Build and Publish Docker Image / build-and-push-tag (pull_request) Has been skipped
97abc74297
- Replace complex single-job conditional steps with 3 separate jobs:
  build-only, build-and-push-main, build-and-push-tag
- Use Gitea Actions-compatible startsWith() function instead of
  .startsWith() method call
- Remove nested parentheses that Gitea Actions cannot parse
- Push only on refs/heads/main and refs/tags/v* (not all branches)
lennie-s force-pushed ci/update-workflow from 9ba8a8b7f9 to 97abc74297 2026-04-09 23:05:36 +00:00 Compare
Author
Collaborator

Fixed the if-expression syntax error. The issue was complex nested parentheses and .startsWith() method calls that Gitea Actions does not support. Resolved by:

  1. Restructuring into 3 separate jobs instead of conditional steps within one job:

    • build-only — runs on all non-main, non-tag pushes (branches, PRs)
    • build-and-push-main — runs only on pushes to refs/heads/main
    • build-and-push-tag — runs only on refs/tags/v*
  2. Replacing .startsWith() method calls with the startsWith() function — Gitea Actions supports startsWith(gitea.ref, 'refs/tags/v') but not gitea.ref.startsWith(...)

  3. Removing complex nested parentheses — the original github.event_name != 'push' || (...) expression had unmatched/misplaced parens that Gitea Actions could not parse.

Workflow should now build. Please re-run the failed action to verify.

Fixed the if-expression syntax error. The issue was complex nested parentheses and `.startsWith()` method calls that Gitea Actions does not support. Resolved by: 1. **Restructuring into 3 separate jobs** instead of conditional steps within one job: - `build-only` — runs on all non-main, non-tag pushes (branches, PRs) - `build-and-push-main` — runs only on pushes to `refs/heads/main` - `build-and-push-tag` — runs only on `refs/tags/v*` 2. **Replacing `.startsWith()` method calls with the `startsWith()` function** — Gitea Actions supports `startsWith(gitea.ref, 'refs/tags/v')` but not `gitea.ref.startsWith(...)` 3. **Removing complex nested parentheses** — the original `github.event_name != 'push' || (...)` expression had unmatched/misplaced parens that Gitea Actions could not parse. Workflow should now build. Please re-run the failed action to verify.
daniel merged commit c0970c066e into main 2026-04-09 23:10:41 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: daniel/email-classifier#8