Actions: Introduce actionlint (#105224)
This commit is contained in:
@@ -37,7 +37,7 @@ jobs:
|
||||
id: current-commit
|
||||
run: |
|
||||
FROM_COMMIT=$(go list -m -json github.com/grafana/alerting | jq -r '.Version' | grep -oP '(?<=-)[a-f0-9]+$')
|
||||
echo "from_commit=$FROM_COMMIT" >> $GITHUB_OUTPUT
|
||||
echo "from_commit=$FROM_COMMIT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Get current branch name
|
||||
id: current-branch-name
|
||||
@@ -47,14 +47,14 @@ jobs:
|
||||
id: latest-commit
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
BRANCH: ${{ steps.current-branch-name.outputs.name }}
|
||||
run: |
|
||||
BRANCH="${{ steps.current-branch-name.outputs.name }}"
|
||||
TO_COMMIT=$(gh api repos/grafana/alerting/commits/$BRANCH --jq '.sha')
|
||||
TO_COMMIT="$(gh api repos/grafana/alerting/commits/"$BRANCH" --jq '.sha')"
|
||||
if [ -z "$TO_COMMIT" ]; then
|
||||
echo "Branch $BRANCH not found in alerting repo, falling back to main branch"
|
||||
exit 1
|
||||
fi
|
||||
echo "to_commit=$TO_COMMIT" >> $GITHUB_OUTPUT
|
||||
echo "to_commit=$TO_COMMIT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Compare commit hashes
|
||||
run: |
|
||||
@@ -74,26 +74,31 @@ jobs:
|
||||
id: check-commits
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
FROM_COMMIT: ${{ steps.current-commit.outputs.from_commit }}
|
||||
TO_COMMIT: ${{ steps.latest-commit.outputs.to_commit }}
|
||||
run: |
|
||||
# get all commits that contains 'Alerting:' in the message
|
||||
ALERTING_COMMITS=$(gh api repos/grafana/alerting/compare/${{ steps.current-commit.outputs.from_commit }}...${{ steps.latest-commit.outputs.to_commit }} \
|
||||
--jq '.commits[].commit.message | split("\n")[0]') || true
|
||||
|
||||
# get all commits that contains 'Alerting:' in the message
|
||||
ALERTING_COMMITS="$(gh api repos/grafana/alerting/compare/"$FROM_COMMIT"..."$TO_COMMIT" \
|
||||
--jq '.commits[].commit.message | split("\n")[0]')" || true
|
||||
|
||||
# Use printf instead of echo -e for better multiline handling
|
||||
printf "%s\n" "$ALERTING_COMMITS"
|
||||
|
||||
|
||||
# make the list for markdown and replace PR numbers with links
|
||||
ALERTING_COMMITS_FORMATTED=$(echo "$ALERTING_COMMITS" | while read -r line; do echo "- $line" | sed -E 's/\(#([0-9]+)\)/[#\1](https:\/\/github.com\/grafana\/grafana\/pull\/\1)/g'; done)
|
||||
|
||||
echo "alerting_commits<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$ALERTING_COMMITS_FORMATTED" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
ALERTING_COMMITS_FORMATTED="$(echo "$ALERTING_COMMITS" | while read -r line; do echo "- $line" | sed -E 's/\(#([0-9]+)\)/[#\1](https:\/\/github.com\/grafana\/grafana\/pull\/\1)/g'; done)"
|
||||
|
||||
{
|
||||
echo "alerting_commits<<EOF"
|
||||
echo "$ALERTING_COMMITS_FORMATTED"
|
||||
echo "EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Update alerting module
|
||||
env:
|
||||
GOSUMDB: off
|
||||
PINNED_COMMIT: ${{ steps.latest-commit.outputs.to_commit }}
|
||||
run: |
|
||||
go get github.com/grafana/alerting@${{ steps.latest-commit.outputs.to_commit }}
|
||||
go get github.com/grafana/alerting@"$PINNED_COMMIT"
|
||||
make update-workspace
|
||||
|
||||
- id: get-secrets
|
||||
@@ -124,7 +129,7 @@ jobs:
|
||||
Compare changes: https://github.com/grafana/alerting/compare/${{ steps.current-commit.outputs.from_commit }}...${{ steps.latest-commit.outputs.to_commit }}
|
||||
<details>
|
||||
<summary>Commits</summary>
|
||||
|
||||
|
||||
${{ steps.check-commits.outputs.alerting_commits }}
|
||||
|
||||
</details>
|
||||
@@ -132,6 +137,10 @@ jobs:
|
||||
Created by: [GitHub Action Job](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
|
||||
- name: Add PR URL to Summary
|
||||
if: steps.create-pr.outputs.pull-request-url != ''
|
||||
env:
|
||||
PR_URL: ${{ steps.create-pr.outputs.pull-request-url }}
|
||||
run: |
|
||||
echo "## Pull Request Created" >> $GITHUB_STEP_SUMMARY
|
||||
echo "🔗 [View Pull Request](${{ steps.create-pr.outputs.pull-request-url }})" >> $GITHUB_STEP_SUMMARY
|
||||
{
|
||||
echo "## Pull Request Created"
|
||||
echo "🔗 [View Pull Request]($PR_URL)"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
Reference in New Issue
Block a user