https://github.com/bh2smith/dune-update
A GitHub Action for saving query changes
https://github.com/bh2smith/dune-update
Last synced: 6 months ago
JSON representation
A GitHub Action for saving query changes
- Host: GitHub
- URL: https://github.com/bh2smith/dune-update
- Owner: bh2smith
- License: mit
- Created: 2024-03-28T08:26:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-21T13:12:22.000Z (almost 2 years ago)
- Last Synced: 2025-04-24T03:13:51.993Z (over 1 year ago)
- Language: JavaScript
- Size: 1.24 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Create a JavaScript Action
[](https://github.com/super-linter/super-linter)

## How to Use this Action
The expected workflow for query updates is that changes to query files are made
through a pull request. One the pull request is merged to main, the action will
trigger an update of all queries that were edited in the PR.
Here is a sample workflow:
```yaml
name: On Merge to Main
on:
push:
branches: [main]
jobs:
update-queries:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Necessary to get a complete history for diff
- name: Install necessary tools
run: sudo apt-get install -y jq # Installing jq for JSON processing
- name: Get list of changed files in "queries" directory
id: get-changed-files
run: |
CHANGED_FILES=$(git diff \
--name-only --diff-filter=ACMRT \
${{ github.event.before }} ${{ github.sha }} \
-- queries | paste -sd "," -)
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT
- name: Update Queries
uses: bh2smith/dune-update@v0.0.0-beta.2
with:
changedQueries: ${{ steps.get-changed-files.outputs.changed_files }}
duneApiKey: ${{ secrets.DUNE_API_KEY }}
```
This expects that queries are saved in `./queries/`. Note that all query file
names must be formatted as `*_{queryId}.sql`.
For a real example of this workflow in action, please visit this
[Demo Project](https://github.com/bh2smith/demo-ts-dune-client)! Specifically
- [this workflow](https://github.com/bh2smith/demo-ts-dune-client/blob/main/.github/workflows/ci.yaml)
and
- [this successful run](https://github.com/bh2smith/demo-ts-dune-client/actions/runs/8479606867/job/23233904550)