Skip to content

.github/workflows/update-to-latest.yaml #94

.github/workflows/update-to-latest.yaml

.github/workflows/update-to-latest.yaml #94

on:
schedule:
- cron: '30 5 * * 2'
workflow_dispatch:
jobs:
n8n_latest_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get latest n8n version
id: n8n_latest_version
run: |
latest_release=$(curl -s https://docs.n8n.io/release-notes/ | grep -oE "latest.*[0-9]+\.[0-9]+\.[0-9]+" | awk -F '[: ]' '{print $3}')
echo "::set-output name=latest_release::$latest_release"
- name: Check actual version
id: check_version
run: echo "::set-output name=actual_version::$(grep -oP '(?<=ARG N8N_VERSION=)[0-9]+\.[0-9]+\.[0-9]+' Dockerfile)"
- name: Check if update is needed
id: check_update
run: echo "::set-output name=update_needed::$(test ${{ steps.check_version.outputs.actual_version }} != ${{ steps.n8n_latest_version.outputs.latest_release }} && echo true || echo false)"
- name: update n8n version in Dockerfile
if: steps.check_update.outputs.update_needed == 'true'
run: |
sed -i "s/N8N_VERSION=.*/N8N_VERSION=${{ steps.n8n_latest_version.outputs.latest_release }}/g" Dockerfile
- name: update addon configuration in config.json
if: steps.check_update.outputs.update_needed == 'true'
run: |
actual_config=$(cat config.json | jq -r ".version" | awk -F"." '{print $3}')
new_config=$((actual_config+1))
actual_version=$(cat config.json | jq -r ".version" | awk -F"." '{print $1"."$2}')
new_version="${actual_version}.${new_config}"
jq ".version = \"${new_version}\"" config.json > config.json.tmp && mv config.json.tmp config.json
sed -i "s/## \[Unreleased\]/## \[Unreleased\]\n\n## [ ${new_version} ] - $(date +%Y-%m-%d) \n\n Bump n8n to ${{ steps.n8n_latest_version.outputs.latest_release }}/g" CHANGELOG.md
- name: update CHANGELOG.md
if: steps.check_update.outputs.update_needed == 'true'
run: |
- name: create pull request
if: steps.check_update.outputs.update_needed == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.CR_PAT }}
commit-message: Update n8n to ${{ steps.n8n_latest_version.outputs.latest_release }}
title: Update n8n to ${{ steps.n8n_latest_version.outputs.latest_release }}
body: |
Update n8n to ${{ steps.n8n_latest_version.outputs.latest_release }}
branch: update-n8n-${{ steps.n8n_latest_version.outputs.latest_release }}
labels: |
n8n
update