sonar-scanner version check #131
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: sonar-scanner version check | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '15 10 * * *' | |
jobs: | |
update-version: | |
name: Prepare pull request for sonar-scanner version update | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- run: sudo apt install -y jq | |
- run: sudo snap install yq | |
- uses: actions/checkout@v4 | |
with: | |
ref: master | |
persist-credentials: true | |
fetch-depth: 0 | |
- name: "Fetch currently used sonar-scanner version" | |
id: tagged-version | |
shell: bash | |
run: cat sonar-scanner-version >> $GITHUB_OUTPUT | |
- name: "Fetch lastest sonar-scanner version" | |
id: latest-version | |
shell: bash | |
run: | | |
./scripts/fetch_latest_version.sh > sonar-scanner-version | |
cat sonar-scanner-version >> $GITHUB_OUTPUT | |
- name: "Update default version" | |
if: steps.tagged-version.outputs.sonar-scanner-version != steps.latest-version.outputs.sonar-scanner-version | |
shell: bash | |
env: | |
NEW_VERSION: ${{ steps.latest-version.outputs.sonar-scanner-version }} | |
run: | | |
yq -i '.inputs.scannerVersion.default = strenv(NEW_VERSION)' action.yml | |
- name: "Create Pull Request for version update" | |
if: steps.tagged-version.outputs.sonar-scanner-version != steps.latest-version.outputs.sonar-scanner-version | |
shell: bash | |
env: | |
UPDATE_BRANCH: update-to-sonar-scanner-${{ steps.latest-version.outputs.sonar-scanner-version }} | |
TITLE: "Update SonarScanner CLI to ${{ steps.latest-version.outputs.sonar-scanner-version }}" | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name "SonarTech" | |
git config --global user.email "sonartech@sonarsource.com" | |
git checkout -b ${UPDATE_BRANCH} | |
git add sonar-scanner-version | |
git add action.yml | |
git commit -m "${TITLE}" | |
git push --force-with-lease origin ${UPDATE_BRANCH} | |
gh pr list | |
if [[ $(gh pr list -H "${UPDATE_BRANCH}" | grep "${UPDATE_BRANCH}" | wc -l) -eq 0 ]]; then | |
gh pr create -B master -H ${UPDATE_BRANCH} --title "${TITLE}" --body "Automatic updated of sonar-scanner version value. Needs to be tagged for release." | |
fi |