From 8fc43f013b3d7b541afb4df12eb3fb2b75af9433 Mon Sep 17 00:00:00 2001 From: Hannah Bollar Date: Wed, 14 Feb 2024 12:19:31 -0800 Subject: [PATCH] build action update for dist checker (#415) Signed-off-by: Hannah Bollar Co-authored-by: github-actions[bot] --- .github/workflows/build.yml | 49 ++++++++++++++++++++++++++++++++++++- dist/index.html | 2 +- samples/index.html | 2 +- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32e18697..da36acf0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,9 +4,11 @@ name: npm run build on: workflow_dispatch: push: + branches: + - '**' # This allows the workflow to run on all branches for the build job permissions: - contents: read + contents: write concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -32,3 +34,48 @@ jobs: - name: 👷 Build run: | npm run build + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: build-artifacts + path: ./dist + + + check-dist: + if: github.ref == 'refs/heads/main' # This job runs only if the current branch is main + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for all tags and branches + + - name: remove potentially old dist + run: | + rm -rf ./dist + + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts + path: ./dist + + - name: check git status + run: | + git status --porcelain && ls -al + + - name: Check for changes + id: check_changes + run: | + if [[ -n $(git status --porcelain) ]]; then + echo "Changes detected. Committing and pushing." + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + commit_message=$'👷 MRjs - Auto Generated Dist 👷\n\nChanges at '"${GITHUB_SHA}" + git add . + git commit -m "$commit_message" + git push --quiet --set-upstream origin HEAD + else + echo "No changes detected. Exiting without committing." + fi diff --git a/dist/index.html b/dist/index.html index c0a5a041..647d8e2b 100644 --- a/dist/index.html +++ b/dist/index.html @@ -9,7 +9,7 @@ - + diff --git a/samples/index.html b/samples/index.html index 647d8e2b..c0a5a041 100644 --- a/samples/index.html +++ b/samples/index.html @@ -9,7 +9,7 @@ - +