Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Fix `always()` logic for dependent tasks in CI/CD workflow (#820)

Madison Swain-Bowdened395bf90fa8
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index 51311a2d0..a953a54c0 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -186,14 +186,14 @@ jobs:
run: just ingestion_server/test-local
- name: Upload ingestion test logs
- if: always()
+ if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: ing_logs
path: ingestion_server/test/ingestion_logs.txt
- name: Print ingestion test logs
- if: always()
+ if: success() || failure()
run: cat ingestion_server/test/ingestion_logs.txt
#######
@@ -233,13 +233,13 @@ jobs:
run: just api/test
- name: Print API test logs
- if: always()
+ if: success() || failure()
run: |
just logs > api_logs
cat api_logs
- name: Upload API test logs
- if: always()
+ if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: api_logs
@@ -596,7 +596,10 @@ jobs:
playwright-test-failure-comment:
name: Post Playwright test debugging instructions
- if: always() && github.event_name == 'pull_request' && (needs.nuxt-playwright-vr.result == 'failure' || needs.nuxt-playwright-e2e.result == 'failure' || needs.storybook-playwright.result == 'failure')
+ if: |
+ (success() || failure()) &&
+ github.event_name == 'pull_request' &&
+ (needs.nuxt-playwright-vr.result == 'failure' || needs.nuxt-playwright-e2e.result == 'failure' || needs.storybook-playwright.result == 'failure')
runs-on: ubuntu-latest
needs:
- nuxt-playwright-e2e
@@ -683,7 +686,7 @@ jobs:
name: Publish full-stack docs
# https://github.com/actions/runner/issues/491#issuecomment-850884422
if: |
- always() &&
+ !failure() && !cancelled() &&
(needs.test-ing.result == 'success' || needs.test-ing.result == 'skipped') &&
(needs.test-api.result == 'success' || needs.test-api.result == 'skipped') &&
(needs.nuxt-build.result == 'success' || needs.nuxt-build.result == 'skipped') &&
@@ -733,7 +736,7 @@ jobs:
name: Preview full-stack docs
# https://github.com/actions/runner/issues/491#issuecomment-850884422
if: |
- always() &&
+ !failure() && !cancelled() &&
(needs.test-ing.result == 'success' || needs.test-ing.result == 'skipped') &&
(needs.test-api.result == 'success' || needs.test-api.result == 'skipped') &&
(needs.nuxt-build.result == 'success' || needs.nuxt-build.result == 'skipped') &&
@@ -848,7 +851,7 @@ jobs:
runs-on: ubuntu-latest
# prevent running on fork PRs
if: |
- always() &&
+ !failure() && !cancelled() &&
(needs.test-ing.result == 'success' || needs.test-ing.result == 'skipped') &&
(needs.test-api.result == 'success' || needs.test-api.result == 'skipped') &&
((github.event_name == 'push' && github.repository == 'WordPress/openverse') || (github.event_name == 'release' && github.repository == 'WordPress/openverse'))
@@ -900,7 +903,10 @@ jobs:
deploy-frontend:
name: Deploy staging frontend
runs-on: ubuntu-latest
- if: github.event_name == 'push' && needs.get-changes.outputs.frontend == 'true'
+ if: |
+ !failure() && !cancelled() &&
+ github.event_name == 'push' && needs.get-changes.outputs.frontend == 'true' &&
+ (needs.nuxt-playwright-e2e.result == 'success' && needs.nuxt-playwright-vr.result == 'success' && needs.storybook-playwright.result == 'success')
needs:
- get-image-tag
- get-changes
@@ -926,7 +932,10 @@ jobs:
deploy-api:
name: Deploy staging API
runs-on: ubuntu-latest
- if: github.event_name == 'push' && (needs.get-changes.outputs.ingestion_server == 'true' || needs.get-changes.outputs.api == 'true')
+ if: |
+ !failure() && !cancelled() &&
+ github.event_name == 'push' && needs.get-changes.outputs.api == 'true' &&
+ (needs.test-ing.result == 'success' && needs.publish-images.result == 'success')
needs:
- get-image-tag
- get-changes