Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

CI/CD: update to skip workflow (but mark as complete) if only CI/D files have been modified (#712)

Rich Turnera7a076ca1d63
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index e3da98e51..7374a4b52 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -60,10 +60,6 @@ on:
- '**'
tags-ignore:
- '*.*'
- paths-ignore:
- - '.github/**'
- - '.ci_cd/**'
- - '**/*.md'
# When a release is published
release:
@@ -102,7 +98,7 @@ jobs:
steps:
- - name: Cancel Previous Runs
+ - name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
@@ -167,8 +163,24 @@ jobs:
with:
# This will only be available when run by workflow_dispatch otherwise will checkout branch/commit that triggered the workflow
ref: ${{ steps.inputs-and-secrets.outputs.COMMIT }}
+ fetch-depth: 0
submodules: recursive
-
+
+ # We use this to exit workflow if only CI/CD files have changed
+ - name: Get changed files
+ id: changed-files
+ uses: tj-actions/changed-files@v20
+ with:
+ files_ignore: |
+ .ci_cd/**
+ **/*.md
+ **/*.yml
+
+ - name: Set skip flag if only CI/CD files have changed
+ id: skip-cicd
+ if: github.event_name == 'push' && steps.changed-files.outputs.only_modified != 'true'
+ run: echo "::set-output name=value::true"
+
- name: Make cache dirs and set file permissions
run: |
chmod +x gradlew
@@ -376,6 +388,7 @@ jobs:
cp -r . ~/manager-tags-old/
- name: Sanitize deployments value
+ if: steps.skip-cicd.outputs.value != 'true'
id: deployments
run: |
deployments=$DEPLOYMENTS
@@ -396,16 +409,17 @@ jobs:
- name: Define backend test command
id: test-backend-command
- if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
+ if: ${{ github.event_name == 'push' && steps.skip-cicd.outputs.value != 'true' }}
run: echo "::set-output name=value::./gradlew -p test test"
- name: Define UI test command
id: test-ui-command
- if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
+ if: ${{ github.event_name == 'push' && steps.skip-cicd.outputs.value != 'true' }}
run: echo ""
- name: Define manager docker build command
id: manager-docker-command
+ if: ${{ steps.skip-cicd.outputs.value != 'true' }}
shell: bash
run: |
if [ $IS_CUSTOM_PROJECT == 'true' ]; then
@@ -439,6 +453,7 @@ jobs:
- name: Define deployment docker build command
id: deployment-docker-command
+ if: ${{ steps.skip-cicd.outputs.value != 'true' }}
shell: bash
run: |
if [ "$DEPLOYMENT_DOCKERFILE_EXISTS" == 'true' ]; then
@@ -465,6 +480,7 @@ jobs:
- name: Define installDist command
id: install-command
+ if: steps.skip-cicd.outputs.value != 'true'
shell: bash
run: |
if [ -n "$MANAGER_DOCKER_CMD" ]; then
@@ -512,6 +528,7 @@ jobs:
- name: Set up JDK 17 and gradle cache
id: java
+ if: steps.skip-cicd.outputs.value != 'true'
uses: actions/setup-java@v3
with:
distribution: 'temurin'
@@ -524,6 +541,7 @@ jobs:
- name: Yarn cache
uses: actions/[email protected]
+ if: steps.skip-cicd.outputs.value != 'true'
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -550,6 +568,7 @@ jobs:
- name: Output info
+ if: steps.skip-cicd.outputs.value != 'true'
run: |
echo "************************************************************"
echo "************** INFO *******************"