1.0.9 • Published 2 years ago

@positioner/psk-appsettings-update v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

PSK Appsettings Update

Automatically update the appsettings.json version with a random string or commit hash

API

This package exposes the command update-appsettings

Usage

A typical CI workflow file should look like this:

jobs:
  build-and-deploy:
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v2
+     with:
+       fetch-depth: 0
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: Build Sass
      run: |
        npm install --no-audit
        gulp sass
-       npx update-appsettings
+   - name: Get latest assets version
+     run: |
+       $API_RESPONSE = $(curl -L -H "Authorization: Bearer ${{ github.token }}" https://api.github.com/repos/${{ github.repository }}/issues/1)
+       $ISSUE_TITLE = echo "$API_RESPONSE" | jq -r '.title'
+       echo "LATEST_ASSETS_VERSION=$ISSUE_TITLE" >> $env:GITHUB_ENV
+   - name: Check for JS/CSS/SCSS changes and update appsettings.json
+     id: appsettings
+     run: |
+       $changedFiles = git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | Select-String -Pattern '\.js$|\.scss$|\.css$'
+       if ($changedFiles) {
+         echo "changedFiles=1" >> $env:GITHUB_OUTPUT
+         npx update-appsettings ${{ github.event.after }}
+       }
+       else {
+         $LATEST_ASSETS_VERSION = $env:LATEST_ASSETS_VERSION
+         if ($LATEST_ASSETS_VERSION -ne "null") {
+           npx update-appsettings $LATEST_ASSETS_VERSION
+         } else {
+           echo "createIssue=1" >> $env:GITHUB_OUTPUT
+           npx update-appsettings ${{ github.event.after }}
+         }
+       }
    [...dotnet stuff...]
    - name: Deploy to Azure WebApp
      uses: azure/webapps-deploy@v2
      with:
        app-name: ${{ env.AZURE_WEBAPP_NAME }}
        package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
        publish-profile: ${{ env.AZURE_WEBAPP_PUBLISH_PROFILE }}
+   - name: Update latest assets version
+     id: updateIssue
+     if: steps.appsettings.outputs.changedFiles == '1'
+     continue-on-error: true
+     shell: bash
+     run: |
+       curl -fL -X PATCH -H "Authorization: Bearer ${{ github.token }}" https://api.github.com/repos/${{ github.repository }}/issues/1 -d '{"title":"${{ github.event.after }}"}'
+   - name: Create latest assets version issue if it doesn't exist
+     if: steps.appsettings.outputs.createIssue == '1' || (steps.appsettings.outputs.changedFiles == '1' && steps.updateIssue.outcome == 'failure')
+     shell: bash
+     run: |
+       curl -L -X POST -H "Authorization: Bearer ${{ github.token }}" https://api.github.com/repos/${{ github.repository }}/issues -d '{"title":"${{ github.event.after }}"}'
   [...notify stuff...]

Release notes

1.0.9 - 03.08.2023

  • Allow script to receive a commit hash as argument
  • Update README.md

1.0.8 - 02.06.2023

  • Update README.md

1.0.7 - 01.06.2023

  • Revert updateAppsettings.js

1.0.6 - 01.06.2023

  • Add more console logs

1.0.5 - 01.06.2023

  • Add more console logs

1.0.4 - 01.06.2023

  • Update appsettings.json only if there are changes to CSS/SCSS/JS files
  • Use the GitHub SHA as the version number instead of a random string

1.0.3 - 29.03.2023

  • Add console logs to understand if the process was successful or not

1.0.2 - 15.03.2022

  • Fix CI usage example in readme

1.0.1 - 14.03.2022

  • Add repository field and release notes

1.0.0 - 14.03.2022

  • Initial release
1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago