Skip to content

Commit

Permalink
add workflow to check for terraform-ls updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Dec 22, 2023
1 parent fe8943b commit da9882d
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
64 changes: 64 additions & 0 deletions .github/workflows/update-check.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}

0 comments on commit da9882d

Please sign in to comment.