Reusable workflows usability

Hi,

I would like to share workflows between several repositories.

From what I understand, this syntax should allow to do what I need :

name: Workflow test

on: [push]

jobs:
  gradle-build:
    uses: MY_HOST/SRC_REPO/.gitea/workflows/WORKFLOW_DEFINITION_FILE.yaml@main
    with:
      ref: main

It seems something is happening as I get errors if I don’t use existing paths or references.

However it’s not working as I am getting this message :

MY-WORKER-1(version:v0.2.11) received task 1084 of job 1035, be triggered by event: push
workflow prepared
evaluating expression 'success()'
expression 'success()' evaluated to 'true'
Early termination

Whats am I missing ?

Regards

Show the workflow you want to call. The ones i use contain the following fields:

on:
  workflow_call:
    inputs:
    secrets:

and work properly

I have started with something very simple :

# MY_PROFILE/PROJECT_B/.gitea/workflows/test.yml
name: Test remote 

on: [push]

jobs:
  gradle-build:
    uses: MY_PROFILE/PROJECT_A/.gitea/workflows/999-dumb.yaml@main
# MY_PROFILE/PROJECT_A/.gitea/workflows/999-dumb.yaml
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on:
  - push
  - workflow_call

jobs:
  Explore-Gitea-Actions:
    runs-on: ubuntu-latest
    steps:
      - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
      - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
      - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
      - name: Check out repository code
        uses: actions/checkout@v4
      - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
      - run: echo "🖥️ The workflow is now ready to test your code on the runner."
      - name: List files in the repository
        run: |
          ls ${{ gitea.workspace }}          
      - run: echo "🍏 This job's status is ${{ job.status }}."

Both repos are public

I have the feeling my syntax is not correct, but I am not able to find any precise documentation for the Gitea flavor of this concept.

My Gitea is self hosted, so I am trying to reuse http://MY_HOST:9080/MY_PROFILE/PROJECT_A/.gitea/workflows/999-dumb.yaml from MY_PROFILE/PROJECT_B located on the same instance.

Both repos are public and have only a “main” branch.

My first attempt was wrong because I was trying to call the workflow within a step, which is reserved to external Actions.

This syntax does not seem to be correct either :

jobs:
  job1:
        uses: MY_PROFILE/PROJECT_A/.gitea/workflows/999-dumb.yaml@main

It give me an error :

stat /root/.cache/act/MY_PROFILE-PROJECT_B@main/.gitea/workflows/999-dumb.yaml: no such file or directory

Adding the repo URL is not accepted as it is not the expected input format.

Can someone provide me a working example ?

Regards

what you trying to do works a bit differently. Reusable “workflows” called actions and they have different format from the workflow itself:

  • create somewhere blank repository “mine-action”
  • create file ‘action.yaml’ in the some sub-folder or root folder, filename is important and should be exactly mentioned one.
  • sample content is like:
name: mine-action
description: some sample action

inputs:
  some_var:
    description: some echo var
    required: true

runs:
  using: "composite"
  steps:
    - name: Steps 
       shell: bash
      run: |
        echo "Passed argument: ${{ inputs.some_var }}"

then it’s possible to use it like:

....
uses: https://githost/path_to_repo[/subdir_if_was_used]@branch
with:
  some_var: "Some text"
....

Here are some more detailed information: github doc

Thank you very much for your answer, I will investigate on it.

I am new to Gitea, and I am not a former Gitlab/Github user either.

So everything is new for me and maybe I am not using the right names or concepts.

What I want to do is quite simple : I have a complex set of tasks to build and manage a software stack, which relies on Ansible role for building (Java sources to Docker images) and deployment (generating docker-compose files, deploy OS packages and generate configuration files here and there).

As each part has become quite complex, it was no more convenient to use a single Ansible role and I decided to split everything. But each role should also be usable independently, for other purposes.

So I have now a Gitea repo for each role, and another one for some kind of “meta role” which provides configuration parameters to imported others (thank to Ansible collections).

The Ansible part is working fine, but of course I am missing the CI/CD part of it

Each role has it’s own actions (run the Docker image building playbook when the source code is modified, run another one to generate configuration files on the deployment host, …)

So I am trying to reuse all the CI/CD definitions by importing them, just like I am importing Ansible roles from the “meta role”. But is it only possible ?

For now I am noodling with copies of the original actions as a POC, but it’s unmaintainable of course and I am sure there is nice way to do it.

I have the feeling this looks like what I am looking for, but I have not been able to get any working result so far but the error message above.

Regards

In fact there was no invocation problem from day one.

There is something wrong with the runner (I am using “gitea/act_runner:latest”).

It seems that after some time, maybe because of a lot of failed tasks, it’s like “polluted” and does not work as it should and returns error messages like the one I got.

Restarting the container was no solution, but destroying it and recreating a fresh one (using the same command line and registration token) allowed everything to run perfectly fine.

But nothing in the logs was clear enough to understand what happened.