Skip to content

Commit

Permalink
Allow mainline branch to be defined programmatically.
Browse files Browse the repository at this point in the history
  • Loading branch information
henrychao-rcsb committed Jul 17, 2023
1 parent c3cdff8 commit e6ea0a8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/workflow-java.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ name: Java Workflow

on:
workflow_call:
inputs:
mainline_branch:
type: string
default: format('refs/heads/{0}', github.event.repository.default_branch)
describe: "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."
workflow_dispatch:
inputs:
mainline_branch:
type: string
default: format('refs/heads/{0}', github.event.repository.default_branch)
describe: "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."

jobs:
# Test projects
Expand Down Expand Up @@ -31,15 +41,15 @@ jobs:
# Staging jobs
build_jib_staging:
name: "Build docker image via jib with staging tag"
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
if: (github.ref == inputs.mainline_branch) && (github.event_name != 'pull_request')
needs:
- build_jib
uses: ./.github/workflows/run_mvn.yaml
with:
script: package jib:build -Djib.to.tags=staging -Djib.target.namespace=rcsb --no-transfer-progress -Dmaven.test.skip=true
skaffold_deploy_staging:
name: "Skaffold deploy into staging namespace"
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
if: (github.ref == inputs.mainline_branch) && (github.event_name != 'pull_request')
needs:
- build_jib_staging
uses: ./.github/workflows/deploy_skaffold.yaml
Expand All @@ -50,14 +60,15 @@ jobs:
# TODO: Increment version of project through workflow. Add this step once we are ready to retire older workflow files.
build_docker_production:
name: "Build docker image via jib with production tag"
if: (github.ref == inputs.mainline_branch) && (github.event_name != 'pull_request')
needs:
- skaffold_deploy_staging
uses: ./.github/workflows/run_mvn.yaml
with:
script: package jib:build -Djib.to.tags=production -Djib.target.namespace=rcsb --no-transfer-progress -Dmaven.test.skip=true
skaffold_deploy_production:
name: Skaffold deploy into production environment"
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
if: (github.ref == inputs.mainline_branch) && (github.event_name != 'pull_request')
needs:
- build_docker_production
uses: ./.github/workflows/deploy_skaffold.yaml
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/workflow-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ name: Node Workflow

on:
workflow_call:
inputs:
mainline_branch:
type: string
default: format('refs/heads/{0}', github.event.repository.default_branch)
describe: "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."
workflow_dispatch:
inputs:
mainline_branch:
type: string
default: format('refs/heads/{0}', github.event.repository.default_branch)
describe: "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."

jobs:
# Build jobs
Expand Down Expand Up @@ -43,6 +53,7 @@ jobs:
# Staging jobs
build_docker_staging:
name: "Build docker image with staging tag"
if: (github.ref == inputs.mainline_branch) && (github.event_name != 'pull_request')
needs:
- test_npm
- build_docker
Expand All @@ -53,7 +64,7 @@ jobs:
additional_tag: "staging"
skaffold_deploy_staging:
name: "Skaffold deploy into staging namespace"
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
if: (github.ref == inputs.mainline_branch) && (github.event_name != 'pull_request')
needs:
- build_docker_staging
uses: ./.github/workflows/deploy_skaffold.yaml
Expand All @@ -63,6 +74,7 @@ jobs:
# Production jobs
build_docker_production:
name: "Build docker image with production tag"
if: (github.ref == inputs.mainline_branch) && (github.event_name != 'pull_request')
needs:
- build_docker_staging
uses: ./.github/workflow/build_docker.yaml
Expand All @@ -72,7 +84,7 @@ jobs:
additional_tag: "production"
skaffold_deploy_production:
name: Skaffold deploy into production environment"
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
if: (github.ref == inputs.mainline_branch) && (github.event_name != 'pull_request')
needs:
- build_docker_production
uses: ./.github/workflows/deploy_skaffold.yaml
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
run-workflow:
name: "Run automated workflow"
uses: rcsb/devops-cicd-github-actions/.github/workflows/workflow-java.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.
```
# Node Projects
Expand Down Expand Up @@ -71,6 +73,8 @@ jobs:
run-workflow:
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.
```

# Docker Projects
Expand Down

0 comments on commit e6ea0a8

Please sign in to comment.