From da9882ddde6cbad30ea04b1554349cbb47bf928b Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 23 Dec 2023 00:01:12 +0100 Subject: [PATCH] add workflow to check for terraform-ls updates --- .github/dependabot.yml | 6 +++ .github/workflows/update-check.yaml | 64 +++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/update-check.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/update-check.yaml b/.github/workflows/update-check.yaml new file mode 100644 index 0000000..ef0c1fb --- /dev/null +++ b/.github/workflows/update-check.yaml @@ -0,0 +1,64 @@ +name: Check/update to latest terraform-ls version + +on: + schedule: + # Ru every day at 7:15 + - cron: 15 7 * * * + workflow_dispatch: + +jobs: + build: + name: Check terraform-ls version + runs-on: ubuntu-latest + + steps: + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y ripgrep + + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.SUBLIMELSP_APP_ID }} + private-key: ${{ secrets.SUBLIMELSP_APP_PRIVATE_KEY }} + + - name: Get latest release of terraform-ls + uses: pozetroninc/github-action-get-latest-release@v0.7.0 + id: latest + with: + excludes: 'prerelease,draft' + repository: 'hashicorp/terraform-ls' + token: ${{ steps.app-token.outputs.token }} + + - name: Set tag output without leading v + id: latest_no_v + run: | + TAG_EXCL_V=${{ steps.latest.outputs.release }} + TAG_EXCL_V=${TAG_EXCL_V/v/} + echo "release=$TAG_EXCL_V" >> "$GITHUB_OUTPUT" + + + - uses: actions/checkout@v4 + with: + ref: main + + - name: Get current TAG from main + id: current + run: | + release=$(rg -o "TAG = '([^']+)'" -r \$1 "plugin.py") + echo "release=$release" >> "$GITHUB_OUTPUT" + + - if: steps.current.outputs.release != steps.latest_no_v.outputs.release + name: Update current version + run: sed -i 's/${{ steps.current.outputs.release }}/${{ steps.latest_no_v.outputs.release }}/' plugin.py + + - if: steps.current.outputs.release != steps.latest_no_v.outputs.release + name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + commit-message: update terraform-ls to ${{ steps.latest_no_v.outputs.release }} + delete-branch: true + title: update terraform-ls to ${{ steps.latest_no_v.outputs.release }} + body: 'Update terraform-ls server to [${{ steps.latest_no_v.outputs.release }}](https://github.com/hashicorp/terraform-ls/releases/tag/${{ steps.latest.outputs.release }})' + token: ${{ steps.app-token.outputs.token }}