auto-update #202
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 | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: | |
| env: | |
| GIT_USER_NAME: github-actions[bot] | |
| GIT_USER_EMAIL: github-actions[bot]@users.noreply.github.com | |
| FLATPAK_ID: com.notesnook.Notesnook | |
| jobs: | |
| flatpak-external-data-checker: | |
| name: "check update (${{ matrix.branch || github.ref_name }})" | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| branch: ["master", ""] | |
| isShedule: | |
| - ${{ github.event_name == 'schedule' }} | |
| exclude: | |
| - branch: "master" | |
| isShedule: false | |
| - branch: "" | |
| isShedule: true | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| ref: ${{ matrix.branch }} | |
| - uses: docker://ghcr.io/flathub/flatpak-external-data-checker:latest | |
| with: | |
| args: --edit-only ${{ env.FLATPAK_ID }}.yml | |
| - name: download node sources | |
| run: wget https://github.com/streetwriters/notesnook/releases/latest/download/generated-sources.json -O generated-sources.json | |
| - name: reset | |
| run: | | |
| git checkout -- ${FLATPAK_ID}.yml *.xml | |
| - name: update electron node version | |
| run: | | |
| set -e | |
| FLATPAK_ID="com.notesnook.Notesnook" | |
| # Extract Electron version from generated-sources.json | |
| ELECTRON_VERSION=$(grep -o 'electron/releases/download/v[0-9.]*' generated-sources.json | head -1 | sed -E 's/.*v([0-9.]+)/\1/') | |
| if [ -z "$ELECTRON_VERSION" ]; then | |
| echo "✗ Error: Could not extract Electron version from generated-sources.json" | |
| exit 1 | |
| fi | |
| echo "Detected Electron version: $ELECTRON_VERSION" | |
| # Show current npm_config_nodedir line | |
| echo "" | |
| echo "Current npm_config_nodedir:" | |
| grep "npm_config_nodedir:" ${FLATPAK_ID}.yml | |
| # Update npm_config_nodedir in the YAML file | |
| sed -i.bak "s|npm_config_nodedir: /run/build/notesnook/flatpak-node/cache/node-gyp/.*|npm_config_nodedir: /run/build/notesnook/flatpak-node/cache/node-gyp/${ELECTRON_VERSION}|" ${FLATPAK_ID}.yml | |
| rm -rf ${FLATPAK_ID}.yml.bak | |
| echo "" | |
| echo "Updated npm_config_nodedir:" | |
| grep "npm_config_nodedir:" ${FLATPAK_ID}.yml | |
| echo "" | |
| echo "✓ Successfully updated npm_config_nodedir to ${ELECTRON_VERSION}" | |
| echo "Done!" | |
| - uses: docker://ghcr.io/flathub/flatpak-external-data-checker:latest | |
| name: recheck and open pr | |
| env: | |
| GIT_AUTHOR_NAME: Flatpak External Data Checker | |
| GIT_COMMITTER_NAME: Flatpak External Data Checker | |
| GIT_AUTHOR_EMAIL: ${{ env.GIT_USER_NAME }} | |
| GIT_COMMITTER_EMAIL: ${{ env.GIT_USER_EMAIL }} | |
| EMAIL: ${{ env.GIT_USER_EMAIL }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| args: --update --never-fork ${{ env.FLATPAK_ID }}.yml |