diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18b6b57..f568e72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,7 @@ -# Continuous Integration workflow to: -# 1. Build, lint, and test project -# 2. Commit any updates to "dist" folder - on: push: branches: - - main + - main pull_request: name: Continuous Integration @@ -13,34 +9,48 @@ name: Continuous Integration jobs: build: runs-on: ubuntu-latest - + steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-node@v2 - with: - node-version: '12' - - - run: npm install - - - run: npm run build - - - run: npm run lint - - - run: npm run test - - - name: Examine changes - run: |- - echo 'FILES_CHANGED<> $GITHUB_ENV - git diff --exit-code dist/index.js >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV - - - name: Update dist - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && env.FILES_CHANGED }} - uses: swinton/commit@v2.x - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: - dist/index.js - commit-message: Update dist \ No newline at end of file + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: '12' + + - run: npm install + + - run: npm run build + + - run: npm run lint + + - run: npm run test + + - name: Upload build artifacts to artifact store + uses: actions/upload-artifact@v3 + with: + name: build-artifacts + path: dist + + Deploy: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Download build artifacts from artifact store + uses: actions/download-artifact@v3 + with: + name: build-artifacts + path: dist + + - name: Upload to blob storage + uses: Azure/cli@1.0.4 + with: + inlineScript: | + az storage blob upload-batch --account-name statichostingwebs -d '$web' -s dist/ + + - name: logout + run: | + az logout + if: always() + diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..45b01de --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,61 @@ +name: Build & Deploy +on: + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: '12' + + - run: npm install + + - run: npm run build + + - run: npm run lint + + - run: npm run test + + - name: Examine changes + run: |- + echo 'FILES_CHANGED<> $GITHUB_ENV + git diff --exit-code dist/index.js >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + + - name: Update dist + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && env.FILES_CHANGED }} + uses: swinton/commit@v2.x + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: + dist/index.js + commit-message: Update dist + Deploy: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Upload to blob storage + uses: Azure/cli@1.0.4 + with: + inlineScript: | + az storage blob upload-batch --account-name staticcontent1 --account-key ${{ secrets.AZURE_STORAGE_KEY }} --auth-mode key --overwrite -d '$web' -s dist/ + + - name: Purge CDN endpoint + uses: azure/CLI@v1 + with: + inlineScript: | + az cdn endpoint purge --content-paths "/*" --profile-name "staticwebsite" --name "staticwebsite123" --resource-group "tester" + - name: logout + run: | + az logout + if: always()