Improve workflow input handling (#34097)
Some checks are pending
API / build (push) Waiting to run
Server CI / Compute Go Version (push) Waiting to run
Server CI / Check mocks (push) Blocked by required conditions
Server CI / Check go mod tidy (push) Blocked by required conditions
Server CI / check-style (push) Blocked by required conditions
Server CI / Check serialization methods for hot structs (push) Blocked by required conditions
Server CI / Vet API (push) Blocked by required conditions
Server CI / Check migration files (push) Blocked by required conditions
Server CI / Generate email templates (push) Blocked by required conditions
Server CI / Check store layers (push) Blocked by required conditions
Server CI / Check mmctl docs (push) Blocked by required conditions
Server CI / Postgres with binary parameters (push) Blocked by required conditions
Server CI / Postgres (push) Blocked by required conditions
Server CI / Postgres (FIPS) (push) Blocked by required conditions
Server CI / Generate Test Coverage (push) Blocked by required conditions
Server CI / Run mmctl tests (push) Blocked by required conditions
Server CI / Run mmctl tests (FIPS) (push) Blocked by required conditions
Server CI / Build mattermost server app (push) Blocked by required conditions
Web App CI / check-lint (push) Waiting to run
Web App CI / check-i18n (push) Waiting to run
Web App CI / check-types (push) Waiting to run
Web App CI / test (push) Waiting to run
Web App CI / build (push) Waiting to run

* Improve workflow input handling by using environment variables with additional input validation and error handling
This commit is contained in:
Lorenzo 2025-10-10 08:35:13 -06:00 committed by GitHub
parent c597b4c70f
commit 5cefad29ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,6 +22,8 @@ jobs:
permissions:
contents: write
runs-on: ubuntu-22.04
env:
COMMIT_SHA: ${{ inputs.commit_sha }}
steps:
- name: release/checkout-mattermost
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@ -32,14 +34,31 @@ jobs:
run: |
echo LATEST_MODULE_TAG=$(git tag --list 'server/public/*' --format='%(refname:lstrip=-1)' --sort -v:refname | head -1) >> ${GITHUB_ENV}
- name: release/validate-commit-sha
run: |
if [ -n "$COMMIT_SHA" ]; then
# Validate commit SHA format (40 character hex string)
if [[ ! "$COMMIT_SHA" =~ ^[a-f0-9]{40}$ ]]; then
echo "Error: Invalid commit SHA format. Must be a 40-character hexadecimal string."
exit 1
fi
# Verify the commit exists in the repository
if ! git cat-file -e "$COMMIT_SHA" 2>/dev/null; then
echo "Error: Commit SHA '$COMMIT_SHA' does not exist in the repository."
exit 1
fi
echo "Commit SHA validation passed: $COMMIT_SHA"
else
echo "No commit SHA provided, will use HEAD"
fi
- name: release/generate-module-release-notes
run: |
echo "RELEASE_NOTES<<EOF" >> ${GITHUB_ENV}
if [ "${{ inputs.commit_sha }}" = "" ];
then
echo "$(git log --oneline --graph --decorate --abbrev-commit server/public/${{ env.LATEST_MODULE_TAG }}...$(git rev-parse HEAD) server/public)" >> ${GITHUB_ENV}
else
echo "$(git log --oneline --graph --decorate --abbrev-commit server/public/${{ env.LATEST_MODULE_TAG }}...${{ inputs.commit_sha }} server/public)" >> ${GITHUB_ENV}
if [ -z "$COMMIT_SHA" ]; then
echo "$(git log --oneline --graph --decorate --abbrev-commit server/public/${{ env.LATEST_MODULE_TAG }}...$(git rev-parse HEAD) server/public)" >> ${GITHUB_ENV}
else
echo "$(git log --oneline --graph --decorate --abbrev-commit server/public/${{ env.LATEST_MODULE_TAG }}...${COMMIT_SHA} server/public)" >> ${GITHUB_ENV}
fi
echo "EOF" >> ${GITHUB_ENV}