From 62ebc413a688a4a999385ae2be982d3dd980bc20 Mon Sep 17 00:00:00 2001 From: Henry Chao Date: Wed, 2 Oct 2024 09:37:25 -0400 Subject: [PATCH] Simplify conditional expression in workflow. --- .github/workflows/workflow-node.yaml | 19 +++++++++---------- README.md | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/workflow-node.yaml b/.github/workflows/workflow-node.yaml index 83288dc..7566048 100644 --- a/.github/workflows/workflow-node.yaml +++ b/.github/workflows/workflow-node.yaml @@ -6,8 +6,8 @@ on: inputs: mainline_branch: type: string - default: ${{ format('refs/heads/{0}', github.event.repository.default_branch) }} - description: "The mainline branch for the repo. Deployments to the staging and production environments are done only on push to this branch. Defaults to the repo's default branch." + default: "master" + description: "The mainline branch for the repo. Deployments to the staging and production environments are done only on push to this branch. Defaults to the master branch." repo_url: type: string default: "harbor.devops.k8s.rcsb.org" @@ -52,8 +52,8 @@ on: inputs: mainline_branch: type: string - default: ${{ format('refs/heads/{0}', github.event.repository.default_branch) }} - description: "The mainline branch for the repo. Deployments to the staging and production environments are done only on push to this branch. Defaults to the repo's default branch." + default: "master" + description: "The mainline branch for the repo. Deployments to the staging and production environments are done only on push to this branch. Defaults to the master branch." repo_url: type: string default: "harbor.devops.k8s.rcsb.org" @@ -92,8 +92,7 @@ jobs: echo "inputs.do_production_build: ${{ inputs.do_production_build }}" echo "github.ref: ${{ github.ref }}" echo "inputs.mainline_branch: ${{ inputs.mainline_branch }}" - echo "formatted mainline_branch: ${{ format('refs/heads/{0}', inputs.mainline_branch) }}" - echo "Is github.ref == format('refs/heads/{0}', inputs.mainline_branch): ${{ github.ref == format('refs/heads/{0}', inputs.mainline_branch) }}" + echo "Is github.ref_name == inputs.mainline_branch: ${{ github.ref_name == inputs.mainline_branch }}" echo "github.event_name: ${{ github.event_name }}" echo "Is github.event_name != 'pull_request': ${{ github.event_name != 'pull_request' }}" echo "inputs.do_staging_build: ${{ inputs.do_staging_build }}" @@ -142,7 +141,7 @@ jobs: name: "Push docker image with staging tag" if: | github.event.inputs.do_staging_build == 'true' && - github.ref == format('refs/heads/{0}', github.event.inputs.mainline_branch) && + github.ref_name == inputs.mainline_branch && github.event_name != 'pull_request' needs: - test_npm @@ -159,7 +158,7 @@ jobs: if: | github.event.inputs.restart_staging_deployment == 'true' && github.event.inputs.staging_k8s_deployment_name && - github.ref == format('refs/heads/{0}', github.event.inputs.mainline_branch) && + github.ref_name == inputs.mainline_branch && github.event_name != 'pull_request' needs: - build_docker_staging @@ -177,7 +176,7 @@ jobs: name: "Push docker image with production tag" if: | github.event.inputs.do_production_build == 'true' && - github.ref == format('refs/heads/{0}', inputs.mainline_branch) && + github.ref_name == inputs.mainline_branch && github.event_name != 'pull_request' needs: - test_npm @@ -194,7 +193,7 @@ jobs: if: | github.event.inputs.restart_production_deployment == 'true' && github.event.inputs.production_k8s_deployment_name && - github.ref == format('refs/heads/{0}', inputs.mainline_branch) && + github.ref_name == inputs.mainline_branch && github.event_name != 'pull_request' needs: - build_docker_production diff --git a/README.md b/README.md index 46389a5..95ab599 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ jobs: name: "Run automated workflow" uses: rcsb/devops-cicd-github-actions/.github/workflows/workflow-node.yaml@master with: - mainline_branch: # The mainline branch for the repo. Deployments to the staging and production environments are done only on push to this branch. Defaults to the repo's default branch. + mainline_branch: # The mainline branch for the repo. Deployments to the staging and production environments are done only on push to this branch. Defaults to the master branch. repo_url: # The URL of the remote Docker image repository. Defaults to harbor.devops.k8s.rcsb.org. repo_project: # REQUIRED. The name of the project or organization in the remote Docker image repository. docker_image_name: # REQUIRED. The name of the Docker image to create.