ci: Allow to use existing docker image from a previous run if provided (#23901)

## Description
- Allow to use existing docker image from a previous run if provided

#### Type of change
- Workflow file changes

## Testing
- Workflow run
This commit is contained in:
Saroj 2023-05-31 12:37:40 +05:30 committed by GitHub
parent 4094d49f06
commit d595eabf8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View File

@ -3,10 +3,17 @@ name: Build Client, Server & Run only Cypress
on:
# This workflow can be triggered manually from the GitHub Actions page
workflow_dispatch:
inputs:
previous_run_id:
description: 'Run id to download the docker image artifact:'
required: false
type: string
default: "0"
jobs:
server-build:
name: server-build
if: inputs.previous_run_id == '0'
uses: ./.github/workflows/server-build.yml
secrets: inherit
with:
@ -15,6 +22,7 @@ jobs:
client-build:
name: client-build
if: inputs.previous_run_id == '0'
uses: ./.github/workflows/client-build.yml
secrets: inherit
with:
@ -23,6 +31,7 @@ jobs:
rts-build:
name: rts-build
if: inputs.previous_run_id == '0'
uses: ./.github/workflows/rts-build.yml
secrets: inherit
with:
@ -31,7 +40,7 @@ jobs:
build-docker-image:
needs: [ client-build, server-build, rts-build ]
# Only run if the build step is successful
if: success()
if: success() && inputs.previous_run_id == '0'
name: build-docker-image
uses: ./.github/workflows/build-docker-image.yml
secrets: inherit
@ -41,9 +50,19 @@ jobs:
ci-test-limited:
needs: [ build-docker-image ]
# Only run if the build step is successful
if: success()
if: success() && inputs.previous_run_id == '0'
name: ci-test-limited
uses: ./.github/workflows/ci-test-limited.yml
secrets: inherit
with:
pr: 0
ci-test-limited-existing-docker-image:
# Only run if the previous run-id is provided
if: inputs.previous_run_id != '0'
name: ci-test-limited
uses: ./.github/workflows/ci-test-limited.yml
secrets: inherit
with:
pr: 0
previous-workflow-run-id: ${{ fromJson(github.event.inputs.previous_run_id) }}

View File

@ -9,6 +9,11 @@ on:
description: "This is the PR number in case the workflow is being called in a pull request"
required: false
type: number
previous-workflow-run-id:
description: "This is the PR number in case the workflow is being called in a pull request"
required: false
type: number
default: 0
jobs:
ci-test-limited:
@ -107,7 +112,17 @@ jobs:
echo "$specs_to_run" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
# In case of run-id provided download the artifact from the previous run
- name: Download Docker image artifact
if: inputs.previous-workflow-run-id != 0
uses: dawidd6/action-download-artifact@v2
with:
name: cicontainer
run_id: ${{ github.event.inputs.previous-workflow-run-id }}
# In case of run-id is 0 download the artifact from the current run
- name: Download Docker image artifact
if: inputs.previous-workflow-run-id != 0
uses: actions/download-artifact@v3
with:
name: cicontainer