Automatically create PR on a new version #1081
This file contains 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: Automatically create PR on a new version | |
on: | |
schedule: | |
- cron: '0 8 * * *' | |
jobs: | |
check_update: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check latest MySQL ODBC driver version | |
run: | | |
echo "LATEST_VERSION=$(curl -s 'https://dev.mysql.com/downloads/connector/odbc/' | grep -oP '<td class=\"col3\">\K.*' | uniq | sed 's/^ *//g' | cut -d'<' -f1)" >> $GITHUB_ENV | |
echo "LATEST_MINOR_VERSION=$(curl -s 'https://dev.mysql.com/downloads/connector/odbc/' | grep -oP '<td class=\"col3\">\K.*' | uniq | sed 's/^ *//g' | cut -d'<' -f1 | cut -d'.' -f-2)" >> $GITHUB_ENV | |
- name: Get version in the repo | |
id: getversion | |
uses: mavrosxristoforos/[email protected] | |
with: | |
xml-file: 'mysql-odbc.nuspec' | |
xpath: "/*[local-name()='package']/*[local-name()='metadata']/*[local-name()='version']" | |
- name: Create URL | |
if: steps.getversion.outputs.info != env.LATEST_VERSION | |
run: echo "URL=https://cdn.mysql.com//Downloads/Connector-ODBC/${{ env.LATEST_MINOR_VERSION }}/mysql-connector-odbc" >> $GITHUB_ENV | |
- name: Calculate SHA256 | |
if: steps.getversion.outputs.info != env.LATEST_VERSION | |
run: | | |
echo "WIN64SHA=$(curl -s ${URL}-${LATEST_VERSION}-winx64.msi | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV | |
- name: Update chocolateyinstall.ps1 file | |
if: steps.getversion.outputs.info != env.LATEST_VERSION | |
run: | | |
sed -i "s|\$url64 .*|\$url64 = '${{ env.URL }}-${{ env.LATEST_VERSION }}-winx64.msi'|g" tools/chocolateyinstall.ps1 | |
sed -i "s/ checksum64 .*/ checksum64 = '${{ env.WIN64SHA }}'/g" tools/chocolateyinstall.ps1 | |
sed -i "s|version>.*<|version>${{ env.LATEST_VERSION }}<|g" mysql-odbc.nuspec | |
- name: Create Pull Request | |
if: steps.getversion.outputs.info != env.LATEST_VERSION | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.PAT }} | |
commit-message: Updating MySQL ODBC driver to ${{ env.LATEST_VERSION }} | |
committer: GitHub <[email protected]> | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
signoff: false | |
base: master | |
branch: ${{ env.LATEST_VERSION }} | |
delete-branch: true | |
title: MySQL ODBC ${{ env.LATEST_VERSION }} | |
body: 'Updated MySQL ODBC driver to ${{ env.LATEST_VERSION }}' | |
labels: | | |
automated pr |