gitops commit koodi commit tekijän nimiin
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 17s
unit-tests Bats test report
CI Feature / Bats tests (push) Successful in 1m26s
acc-tests Cucumber test report
CI Feature / Cucumber tests (push) Successful in 2m16s
CI Feature / Report Summary (push) Successful in 5s
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 17s
unit-tests Bats test report
CI Feature / Bats tests (push) Successful in 1m26s
acc-tests Cucumber test report
CI Feature / Cucumber tests (push) Successful in 2m16s
CI Feature / Report Summary (push) Successful in 5s
This commit is contained in:
@@ -53,12 +53,20 @@ jobs:
|
||||
ID=$(date +%s | md5sum | head -c 8)
|
||||
echo "dispatch_id=$ID" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Resolve commit author
|
||||
id: author
|
||||
run: |
|
||||
echo "name=$(git log -1 --format='%an')" >> "$GITHUB_OUTPUT"
|
||||
echo "email=$(git log -1 --format='%ae')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Dispatch to GitOps repo
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITOPS_DISPATCH_TOKEN }}
|
||||
run: |
|
||||
INPUTS=$(jq -nc \
|
||||
--arg dispatch_id "${{ steps.gen.outputs.dispatch_id }}" \
|
||||
--arg author_name "${{ steps.author.outputs.name }}" \
|
||||
--arg author_email "${{ steps.author.outputs.email }}" \
|
||||
--arg file "$GITOPS_FILE" \
|
||||
--arg yq_tpl "$GITOPS_YQ_TPL" \
|
||||
--arg version "$GITOPS_VERSION" \
|
||||
@@ -66,7 +74,7 @@ jobs:
|
||||
--arg source_commit "$GITOPS_SOURCE_COMMIT" \
|
||||
--arg git_tag_prefix "${GITOPS_TAG_PREFIX:-}" \
|
||||
--arg extra_cmd "${GITOPS_EXTRA_CMD:-}" \
|
||||
'{dispatch_id: $dispatch_id, file: $file, yq_tpl: $yq_tpl, version: $version, source_repo: $source_repo, source_commit: $source_commit, git_tag_prefix: $git_tag_prefix, extra_cmd: $extra_cmd}')
|
||||
'{dispatch_id: $dispatch_id, author_name: $author_name, author_email: $author_email, file: $file, yq_tpl: $yq_tpl, version: $version, source_repo: $source_repo, source_commit: $source_commit, git_tag_prefix: $git_tag_prefix, extra_cmd: $extra_cmd}')
|
||||
curl -s -X POST \
|
||||
"${GITEA_API_URL}/api/v1/repos/${GITOPS_REPO}/actions/workflows/${GITOPS_WORKFLOW}/dispatches" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
|
||||
@@ -23,7 +23,9 @@ INPUTS=$(jq -nc \
|
||||
--arg source_commit "$GITOPS_SOURCE_COMMIT" \
|
||||
--arg git_tag_prefix "${GITOPS_TAG_PREFIX:-}" \
|
||||
--arg extra_cmd "${GITOPS_EXTRA_CMD:-}" \
|
||||
'{file: $file, yq_tpl: $yq_tpl, version: $version, source_repo: $source_repo, source_commit: $source_commit, git_tag_prefix: $git_tag_prefix, extra_cmd: $extra_cmd}')
|
||||
--arg author_name "${GIT_USER_NAME:-}" \
|
||||
--arg author_email "${GIT_USER_EMAIL:-}" \
|
||||
'{file: $file, yq_tpl: $yq_tpl, version: $version, source_repo: $source_repo, source_commit: $source_commit, git_tag_prefix: $git_tag_prefix, extra_cmd: $extra_cmd, author_name: $author_name, author_email: $author_email}')
|
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
echo "gitops-dispatch: dispatching to $GITOPS_REPO/$GITOPS_WORKFLOW..."
|
||||
|
||||
@@ -98,8 +98,8 @@ _gitops_update() {
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git -c user.name="gitea-ci-bot" \
|
||||
-c user.email="ci@keskikuja.site" \
|
||||
git -c user.name="${GIT_USER_NAME:-gitea-ci-bot}" \
|
||||
-c user.email="${GIT_USER_EMAIL:-ci@keskikuja.site}" \
|
||||
commit -m "[skip ci] gitops: update version to ${VERSION}" || _gitops_fail "Failed to commit"
|
||||
GITOPS_SHA="$(git rev-parse HEAD)"
|
||||
git push || _gitops_fail "Failed to push"
|
||||
|
||||
@@ -59,6 +59,12 @@ on:
|
||||
extra_cmd:
|
||||
required: false
|
||||
type: string
|
||||
author_name:
|
||||
required: false
|
||||
type: string
|
||||
author_email:
|
||||
required: false
|
||||
type: string
|
||||
|
||||
env:
|
||||
INPUT_FILE: ${{ inputs.file }}
|
||||
@@ -70,6 +76,8 @@ env:
|
||||
GITEA_API_URL: ${{ gitea.server_url }}
|
||||
GIT_TAG_PREFIX: ${{ inputs.git_tag_prefix || '' }}
|
||||
GITOPS_EXTRA_CMD: ${{ inputs.extra_cmd || '' }}
|
||||
GIT_USER_NAME: ${{ inputs.author_name || '' }}
|
||||
GIT_USER_EMAIL: ${{ inputs.author_email || '' }}
|
||||
|
||||
jobs:
|
||||
update:
|
||||
@@ -153,6 +161,8 @@ gitops-update:
|
||||
|
||||
When `GITOPS_EXTRA_CMD` is set, the script runs it after `yq` and stages all changes (`git add -A`) instead of only the input file — so any files generated by the extra command (e.g. `Chart.lock`, `charts/`) are included in the commit.
|
||||
|
||||
By default the GitOps commit is made as `gitea-ci-bot`. To use the original commit author instead, the dispatch workflow resolves it automatically from the consumer repo — no extra config needed. Just ensure the GitOps repo's `gitops-service.yaml` template has the `author_name` and `author_email` inputs and env mappings.
|
||||
|
||||
### 2.3 Parameters
|
||||
|
||||
| Input | Required | Description |
|
||||
|
||||
Reference in New Issue
Block a user