88 # Trigger action manually from GitHub > Actions
99 workflow_dispatch :
1010 # Trigger action at a given date and time
11- # schedule:
12- # - cron: '37 13 * * *'
11+ schedule :
12+ - cron : ' 47 12 * * 3'
13+
14+ concurrency :
15+ group : privesccheck-update-and-build
1316
1417#
1518# Below, we are building the following chain:
3134 runs-on : ubuntu-latest
3235 outputs :
3336 data-updated : ${{ steps.commit-and-push.outputs.data-updated }}
37+ data-update-diff : ${{ steps.commit-and-push.outputs.data-update-diff }}
3438 steps :
3539 - name : Check out master branch
3640 uses : actions/checkout@v5
4953 run : |
5054 if ! bash ./.github/workflows/commit_and_push.sh "${{ github.actor_id }}" "${{ github.actor }}"; then
5155 echo "data-updated=false" >> "$GITHUB_OUTPUT"
56+ echo "data-update-diff=$(echo "N/A" | base64 -w 0)" >> "$GITHUB_OUTPUT"
5257 else
5358 echo "data-updated=true" >> "$GITHUB_OUTPUT"
59+ echo "data-update-diff=$(git diff --name-only -- ./data | base64 -w 0)" >> "$GITHUB_OUTPUT"
5460 fi
5561
5662 get-release-tag :
8187 uses : actions/checkout@v5
8288 with :
8389 ref : master
90+ fetch-depth : 0
91+ - name : Generate Changelog
92+ shell : bash
93+ run : |
94+ event_name="${{ github.event_name }}"
95+ echo "[*] Event name: ${event_name}"
96+ changelog_content=""
97+ if [[ "${event_name}" == "push" ]]; then
98+ echo "[*] Commit ID before push: ${{ github.event.before }}"
99+ echo "[*] Commit ID after push: ${{ github.event.after }}"
100+ changelog_content="$(git diff --unified=0 "${{ github.event.before }}" "${{ github.event.after }}" -- "./info/CHANGELOG.md" 2>/dev/null | grep -E "^\\+" | grep -v '+++' | sed "s/^+//g")"
101+ elif [[ "${event_name}" == "schedule" ]]; then
102+ data_file_update=$(echo "${{ needs.update-data.outputs.data-update-diff }}" | base64 -d)
103+ echo -e "[*] Data file update:\n${data_file_update}"
104+ changelog_content="## Files updated\n\n${data_file_update}"
105+ else
106+ changelog_content="N/A"
107+ fi
108+ echo -ne "# Changelog\n\n${changelog_content}\n" > ./release/changelog.md
84109 - name : Build PrivescCheck script
85110 shell : pwsh
86111 run : |
@@ -102,10 +127,24 @@ jobs:
102127 echo "[*] Release tag: ${RELEASE_TAG}"
103128 echo "[*] Data updated: ${DATA_UPDATED}"
104129 echo "[*] Event name: ${event_name}"
130+ create_release=0
105131 if [[ "${event_name}" = "schedule" ]]; then
106132 if [[ "${DATA_UPDATED}" = "true" ]]; then
133+ create_release=1
134+ gh release create "${RELEASE_TAG}" ./release/*.ps1
135+ fi
136+ else
137+ create_release=1
138+ fi
139+ if [[ $create_release == 1 ]]; then
140+ changelog_path="./release/changelog.md"
141+ if [[ -f "${changelog_path}" ]]; then
142+ echo "[*] Changelog file found: ${changelog_path}"
143+ gh release create "${RELEASE_TAG}" --notes-file "${changelog_path}" ./release/*.ps1
144+ else
145+ echo "[!] Changelog file not found"
107146 gh release create "${RELEASE_TAG}" ./release/*.ps1
108147 fi
109148 else
110- gh release create "${RELEASE_TAG}" ./release/*.ps1
149+ echo "[*] No release to create"
111150 fi
0 commit comments