This commit is contained in:
@@ -68,6 +68,8 @@ jobs:
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
git restore --staged ${{ gitea.workspace }}/clusters/$cluster/helm
|
||||||
|
|
||||||
# - name: Create Pull Request
|
# - name: Create Pull Request
|
||||||
# id: pull-request
|
# id: pull-request
|
||||||
# uses: peter-evans/create-pull-request@v7
|
# uses: peter-evans/create-pull-request@v7
|
||||||
@@ -96,6 +98,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
if git status --porcelain | grep -q .; then
|
if git status --porcelain | grep -q .; then
|
||||||
echo ">> Changes detected"
|
echo ">> Changes detected"
|
||||||
|
git status --porcelain
|
||||||
echo "changes-detected=true" >> $GITEA_OUTPUT
|
echo "changes-detected=true" >> $GITEA_OUTPUT
|
||||||
else
|
else
|
||||||
echo ">> No changes detected, skipping PR creation"
|
echo ">> No changes detected, skipping PR creation"
|
||||||
@@ -109,16 +112,19 @@ jobs:
|
|||||||
BRANCH_NAME="auto/update-manifests-$(date +%s)"
|
BRANCH_NAME="auto/update-manifests-$(date +%s)"
|
||||||
|
|
||||||
# Configure Git
|
# Configure Git
|
||||||
|
echo ">> Configure git to use gitea-bot as user ..."
|
||||||
git config user.name "gitea-bot"
|
git config user.name "gitea-bot"
|
||||||
git config user.email "gitea-bot@alexlebens.net"
|
git config user.email "gitea-bot@alexlebens.net"
|
||||||
|
|
||||||
# Create a new branch and stage all changes
|
# Create a new branch and stage all changes
|
||||||
|
echo ">> Creating and commiting to $BRANCH_NAME ..."
|
||||||
git checkout -b $BRANCH_NAME
|
git checkout -b $BRANCH_NAME
|
||||||
git add .
|
git add .
|
||||||
git commit -m "chore: Update manifests after change"
|
git commit -m "chore: Update manifests after change"
|
||||||
|
|
||||||
# Push the new branch to the remote repository
|
# Push the new branch to the remote repository
|
||||||
REPO_URL="${{ secrets.REPO_URL }}/${{ gitea.repository }}"
|
REPO_URL="${{ secrets.REPO_URL }}/${{ gitea.repository }}"
|
||||||
|
echo ">> Pushing changes to $REPO_URL ..."
|
||||||
git push -u "https://oauth2:${{ secrets.BOT_TOKEN }}@$(echo $REPO_URL | sed -e 's|https://||')" $BRANCH_NAME
|
git push -u "https://oauth2:${{ secrets.BOT_TOKEN }}@$(echo $REPO_URL | sed -e 's|https://||')" $BRANCH_NAME
|
||||||
|
|
||||||
echo "HEAD_BRANCH=$BRANCH_NAME" >> $GITEA_OUTPUT
|
echo "HEAD_BRANCH=$BRANCH_NAME" >> $GITEA_OUTPUT
|
||||||
@@ -134,19 +140,37 @@ jobs:
|
|||||||
REPO: ${{ gitea.repository_name }}
|
REPO: ${{ gitea.repository_name }}
|
||||||
HEAD_BRANCH: ${{ steps.commit-push.outputs.HEAD_BRANCH }}
|
HEAD_BRANCH: ${{ steps.commit-push.outputs.HEAD_BRANCH }}
|
||||||
run: |
|
run: |
|
||||||
|
API_ENDPOINT="${GITEA_URL}/api/v1/repos/${OWNER}/${REPO}/pulls"
|
||||||
|
|
||||||
|
PAYLOAD=$(cat <<-EOF
|
||||||
|
{
|
||||||
|
"head": "${HEAD_BRANCH}",
|
||||||
|
"base": "${BASE_BRANCH}",
|
||||||
|
"title": "Automated Manifest Update: $(date +%F)",
|
||||||
|
"body": "This PR contains newly rendered Kubernetes manifests automatically generated by the CI workflow.",
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
echo ">> Creating PR from branch: ${HEAD_BRANCH} into ${BASE_BRANCH}"
|
echo ">> Creating PR from branch: ${HEAD_BRANCH} into ${BASE_BRANCH}"
|
||||||
|
|
||||||
apt update && apt install tea
|
curl -X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
tea pulls create \
|
-H "Content-Type: application/json" \
|
||||||
--repo "${OWNER}/${REPO}" \
|
--data "${PAYLOAD}" \
|
||||||
--head "${HEAD_BRANCH}" \
|
"${API_ENDPOINT}"
|
||||||
--base "${BASE_BRANCH}" \
|
|
||||||
--title "Automated Manifest Update: $(date +%F)" \
|
|
||||||
--body "This PR contains newly rendered Kubernetes manifests automatically generated by the CI workflow."
|
|
||||||
|
|
||||||
echo "pull-request-operation=created" >> $GITEA_OUTPUT
|
echo "pull-request-operation=created" >> $GITEA_OUTPUT
|
||||||
|
|
||||||
|
|
||||||
|
- name: Cleanup Branch
|
||||||
|
if: failure() && steps.create-pull-request.outcome == 'failure'
|
||||||
|
env:
|
||||||
|
HEAD_BRANCH: ${{ steps.commit-push.outputs.HEAD_BRANCH }}
|
||||||
|
run: |
|
||||||
|
echo ">> Removing branch: ${HEAD_BRANCH}"
|
||||||
|
git push origin --delete ${HEAD_BRANCH}
|
||||||
|
|
||||||
# - name: ntfy Created
|
# - name: ntfy Created
|
||||||
# uses: niniyas/ntfy-action@master
|
# uses: niniyas/ntfy-action@master
|
||||||
# if: steps.create-pull-request.outputs.pull-request-operation == 'created'
|
# if: steps.create-pull-request.outputs.pull-request-operation == 'created'
|
||||||
|
|||||||
Reference in New Issue
Block a user