Socket
Book a DemoInstallSign in
Socket

@positioner/psk-appsettings-update

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@positioner/psk-appsettings-update

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

1.0.9
latest
Source
npmnpm
Version published
Weekly downloads
70
22.81%
Maintainers
3
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 03 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.