Skip to content

h #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

h #90

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 45 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,56 @@
# 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

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<<EOF' >> $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
- 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()

61 changes: 61 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -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<<EOF' >> $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()