@positioner/psk-appsettings-update
v1.0.9
Published
Automatically update the appsettings.json version with a random string or commit hash
Downloads
249
Readme
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
- Allow script to receive a commit hash as argument
- Update README.md
- Update README.md
- Revert updateAppsettings.js
- Add more console logs
- Add more console logs
- 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
- Add console logs to understand if the process was successful or not
- Fix CI usage example in readme
- Add repository field and release notes
- Initial release