Skip to content

Commit

Permalink
fix: amend digest update workflow
Browse files Browse the repository at this point in the history
geonetci has no ability to modify PR's and when run this way breaks the automation. it would be easier to manage if it makes multiple PR's than the current solution
  • Loading branch information
Mossman1215 committed Apr 5, 2024
1 parent 7ff474b commit 2e88aa7
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions .github/workflows/update-image-digests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,13 @@ jobs:
if git ls-files --others --modified --deleted --exclude-standard | grep -E 'config.yaml'; then
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: determine existing branch
id: branch
if: ${{ steps.determine-changes.outputs.changes == 'true' }}
run: |
TIMESTAMP="$(git log -n1 --pretty='format:%cd' --date=format:'%Y-%m-%d-%H-%M')"
NEW_BRANCH="config-yaml-image-update-for-${TIMESTAMP}"
EXISTING_BRANCH="$(gh pr list --label image-digest-update --json author,title,headRefName | jq -r '. | select(.[] | .title | contains("update sync config.yaml")) | select(.[] | .author.login | contains("github-actions[bot]")) | .[0].headRefName')"
if [ -n "$EXISTING_BRANCH" ]; then
NEW_BRANCH="$EXISTING_BRANCH"
echo "has-existing=true" >> $GITHUB_OUTPUT
fi
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT
echo "new-branch-name=$NEW_BRANCH" >> $GITHUB_OUTPUT
- name: commit and push if there are changes
if: ${{ steps.determine-changes.outputs.changes == 'true' }}
env:
TIMESTAMP: ${{ steps.branch.outputs.timestamp }}
NEW_BRANCH: ${{ steps.branch.outputs.new-branch-name }}
HAS_EXISTING: ${{ steps.branch.outputs.has-existing }}
GH_TOKEN: ${{ secrets.GH_CI_USER_TOKEN }}
run: |
TIMESTAMP="$(git log -n1 --pretty='format:%cd' --date=format:'%Y-%m-%d-%H-%M')"
NEW_BRANCH="config-yaml-image-update-for-${TIMESTAMP}"
git add ./config.yaml
git branch "${NEW_BRANCH}"
git checkout "${NEW_BRANCH}"
Expand All @@ -58,8 +44,4 @@ jobs:
if ! gh label list --json name --jq .[].name | grep -Eq '^image-digest-update$'; then
gh label create image-digest-update || true
fi
ACTION=create
if [ "$HAS_EXISTING" = true ]; then
ACTION=edit
fi
gh pr --label image-digest-update "$ACTION" --title "Update sync config.yaml images ${TIMESTAMP}" --body "updates sync config.yaml images for ${TIMESTAMP}"
gh pr --label image-digest-update create --title "Update sync config.yaml images ${TIMESTAMP}" --body "updates sync config.yaml images for ${TIMESTAMP}"

0 comments on commit 2e88aa7

Please sign in to comment.