Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 47 additions & 24 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,22 @@
#
# DEPLOY_ENC_KEY - key for decrypting deploymnet ssh key residing in config/deploy_id_rsa_enc (see miloserdow/capistrano-deploy)
# this SSH key is used for accessing jump host, UI nodes, and private github repo.

name: Capistrano Deployment
# Controls when the action will run.

permissions:
contents: read

on:
push:
branches:
- master
- develop
# Trigger deployment to staging after unit test action completes
workflow_run:
workflows: ["Ruby Unit Tests"]
types:
- completed
branches: [master, develop]
branches: [develop] # trigger auto deployment to staging from develop branch
# Allows running this workflow manually from the Actions tab
workflow_dispatch:
branches: [master, develop]
inputs:
BRANCH:
branch:
description: 'Branch/tag to deploy'
default: develop
required: true
Expand All @@ -46,36 +43,62 @@ on:

jobs:
deploy:
concurrency:
group: deploy
runs-on: ubuntu-latest
# run deployment only if "Ruby Unit Tests" workflow completes sucessefully or when manually triggered
if: ${{ (github.event.workflow_run.conclusion == 'success') || (github.event_name == 'workflow_dispatch') }}
# run deployment only if "Ruby Unit Tests" workflow completes sucessefully
# or when manually triggered
if: >
(github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success') ||
(github.event_name == 'workflow_dispatch')
env:
BUNDLE_WITHOUT: default #install gems required primarily for the deployment in order to speed this workflow
BUNDLE_WITHOUT: default:test:development #install gems required primarily for the deployment in order to speed this workflow
PRIVATE_CONFIG_REPO: ${{ format('git@github.com:{0}.git', secrets.CONFIG_REPO) }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: set branch/tag and environment to deploy from inputs
run: |
# workflow_dispatch default input doesn't get set on push so we need to set defaults
# via shell parameter expansion
# https://dev.to/mrmike/github-action-handling-input-default-value-5f2g
USER_INPUT_BRANCH=${{ inputs.branch }}
echo "BRANCH=${USER_INPUT_BRANCH:-develop}" >> $GITHUB_ENV
USER_INPUT_ENVIRONMENT=${{ inputs.environment }}
echo "TARGET=${USER_INPUT_ENVIRONMENT:-staging}" >> $GITHUB_ENV
if [ "${{ github.event_name }}" = "workflow_run" ]; then
# Auto: always deploy develop to staging
echo "BRANCH=develop" >> "$GITHUB_ENV"
# echo "BRANCH=${{ github.event.workflow_run.head_branch }}" >> "$GITHUB_ENV" # auto deploy from branch if needed
echo "TARGET=staging" >> "$GITHUB_ENV"
else
# Manual: use inputs, with defaulting via parameter expansion
USER_INPUT_BRANCH=${{ inputs.branch }}
USER_INPUT_ENVIRONMENT=${{ inputs.environment }}

echo "BRANCH=${USER_INPUT_BRANCH:-develop}" >> "$GITHUB_ENV"
echo "TARGET=${USER_INPUT_ENVIRONMENT:-staging}" >> "$GITHUB_ENV"
fi
- name: Provide deployment info
run: |
echo "=== Deployment Details ======================================"
echo "Time: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
echo "Branch/Tag: ${BRANCH}"
echo "Environment: ${TARGET}"
echo "Commit: ${GITHUB_SHA}"
echo "Triggered by: ${GITHUB_ACTOR}"
echo "Event: ${GITHUB_EVENT_NAME}"
if [ "${GITHUB_EVENT_NAME}" = "workflow_run" ]; then
echo "Mode: auto-deploy from develop"
else
echo "Mode: manual deployment"
fi
echo "=============================================================="
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: get-deployment-config
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
repository: ${{ secrets.CONFIG_REPO }} # repository containing deployment settings
token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT
path: deploy_config
path: deploy_config
- name: copy-deployment-config
run: cp -r deploy_config/ontologies_api/* .
run: cp -r deploy_config/ontologies_api/* .
# add ssh hostkey so that capistrano doesn't complain
- name: Add jumphost's hostkey to Known Hosts
run: |
Expand Down
12 changes: 6 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ gem 'haml', '~> 5.2.2' # pin see https://github.com/ncbo/ontologies_api/pull/107
gem 'redcarpet'

# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'goo', github: 'ncbo/goo', branch: 'develop'
gem 'ncbo_annotator', github: 'ncbo/ncbo_annotator', branch: 'develop'
gem 'ncbo_cron', github: 'ncbo/ncbo_cron', branch: 'develop'
gem 'ncbo_ontology_recommender', github: 'ncbo/ncbo_ontology_recommender', branch: 'develop'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'develop'
gem 'goo', github: 'ncbo/goo', branch: 'master'
gem 'ncbo_annotator', github: 'ncbo/ncbo_annotator', branch: 'master'
gem 'ncbo_cron', github: 'ncbo/ncbo_cron', branch: 'master'
gem 'ncbo_ontology_recommender', github: 'ncbo/ncbo_ontology_recommender', branch: 'master'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'master'
gem 'sparql-client', github: 'ncbo/sparql-client', tag: 'v6.3.0'

group :development do
Expand Down Expand Up @@ -82,4 +82,4 @@ group :test do
gem 'webmock', '~> 3.19.1'
gem 'webrick'
gem 'minitest-bisect'
end
end
20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/ncbo/goo.git
revision: b92ae7ab3d2fad40a8b4a7563047c7157765472c
branch: develop
revision: 5cac44e06a6bf0c093563dad66240ab07fec4d9c
branch: master
specs:
goo (0.0.2)
addressable (~> 2.8)
Expand All @@ -16,8 +16,8 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_annotator.git
revision: 55e8cbfac358b2c40deb0bd963bfe6dee91e8347
branch: develop
revision: 4fb9114b80b99f0a654c7f70aaa96839c74fc615
branch: master
specs:
ncbo_annotator (0.0.1)
goo
Expand All @@ -27,8 +27,8 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_cron.git
revision: 111c7263d8a98b1e8f7c033cb0b7d9c6cc10cd01
branch: develop
revision: 7ee2651664e411945c878133073351f817ff6b8d
branch: master
specs:
ncbo_cron (0.0.1)
dante
Expand All @@ -45,8 +45,8 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_ontology_recommender.git
revision: 76d9516adc3c5c6d5c95f21f307bdd60eb3e0acd
branch: develop
revision: c6a18eb7700b23a1a4f1e32ebc94003bf75efe93
branch: master
specs:
ncbo_ontology_recommender (0.0.1)
goo
Expand All @@ -56,8 +56,8 @@ GIT

GIT
remote: https://github.com/ncbo/ontologies_linked_data.git
revision: 9cae83def8a2a4a9bd1a3a1e8388c595c339ce72
branch: develop
revision: 1a6d42628cfcf1704b96de45e27e81392333e343
branch: master
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand Down
2 changes: 1 addition & 1 deletion controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def create_ontology
ont.bring(:viewingRestriction)
ont.bring(:administeredBy)
ont.bring(:acl)
check_access(ont)
check_write_access(ont)
latest_any = ont.latest_submission(status: :any)

if latest_any
Expand Down