Auto update n8n #17
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: Auto update n8n | |
| on: | |
| schedule: | |
| - cron: '7 0 * * 1-5' | |
| timezone: 'America/Chicago' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| jobs: | |
| update: | |
| permissions: | |
| actions: write | |
| contents: write | |
| runs-on: ubuntu-slim | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Get n8n latest version | |
| id: n8n | |
| run: | | |
| version=$(gh api repos/n8n-io/n8n/releases?per_page=10 -q 'map(select(.tag_name != null and .prerelease == false and (.tag_name | startswith("n8n@2."))))[0].tag_name') | |
| if [[ "$version" != *"n8n@2"* ]]; then exit 1; fi | |
| echo version=${version#n8n@} >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Update n8n version | |
| run: sed -i -E "s|(n8nio/n8n:)([0-9]+\\.[0-9]+\\.[0-9]+)|\1$version|" fly.toml | |
| env: | |
| version: ${{ steps.n8n.outputs.version }} | |
| - name: Add and commit fly.toml | |
| id: add-and-commit | |
| uses: EndBug/add-and-commit@v10 | |
| with: | |
| add: fly.toml | |
| default_author: github_actions | |
| message: 'chore: Update n8n to ${{ steps.n8n.outputs.version }}' | |
| - name: Deploy to fly.io | |
| if: steps.add-and-commit.outputs.committed == 'true' | |
| run: gh workflow run deploy.yaml | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} |