-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from hathitrust/deploy-to-testing
Add github workflows
- Loading branch information
Showing
9 changed files
with
219 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Docker Build | ||
|
||
on: | ||
workflow_run: | ||
workflows: [ 'Run CI'] | ||
branches: [ 'main' ] | ||
types: [ completed ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: hathitrust/github_actions/build@v1 | ||
with: | ||
image: ghcr.io/hathitrust/oai_solr-unstable | ||
dockerfile: Dockerfile.prod | ||
tag: ${{ github.sha }} | ||
push_latest: true | ||
registry_token: ${{ github.token }} | ||
|
||
deploy-staging: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
environment: staging | ||
steps: | ||
- name: Deploy to ${{ env.environment }} | ||
uses: mlibrary/deploy-to-kubernetes@v1 | ||
with: | ||
github_username: ${{ github.actor }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
image: hathitrust/oai_solr-unstable:${{ github.sha }} | ||
cluster_ca: ${{ secrets.KUBERNETES_CA }} | ||
cluster_server: ${{ secrets.KUBERNETES_SERVER }} | ||
namespace_token: ${{ secrets.KUBERNETES_TOKEN }} | ||
namespace: ${{ secrets.KUBERNETES_NAMESPACE }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
name: Manual Image Build | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: tag | ||
required: true | ||
|
||
jobs: | ||
build_manual: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: hathitrust/github_actions/build@v1 | ||
with: | ||
dockerfile: Dockerfile.prod | ||
image: ghcr.io/hathitrust/oai_solr-unstable | ||
tag: ${{ github.event.inputs.tag }} | ||
push_latest: false | ||
registry_token: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Deploy to Production | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: Release | ||
required: true | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: production | ||
steps: | ||
- name: Deploy to Production | ||
uses: mlibrary/deploy-to-kubernetes@v2 | ||
with: | ||
registry_username: ${{ github.actor }} | ||
registry_token: ${{ secrets.GITHUB_TOKEN }} | ||
image: ghcr.io/hathitrust/oai_solr:${{ github.event.inputs.tag }} | ||
cluster_ca: ${{ secrets.KUBERNETES_CA }} | ||
cluster_server: ${{ secrets.KUBERNETES_SERVER }} | ||
namespace_token: ${{ secrets.KUBERNETES_TOKEN }} | ||
namespace: ${{ secrets.KUBERNETES_NAMESPACE }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Manual Deploy to Testing | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: tag | ||
required: true | ||
|
||
env: | ||
environment: testing | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: hathitrust/github_actions/build@v1 | ||
with: | ||
dockerfile: Dockerfile.prod | ||
image: ghcr.io/hathitrust/oai_solr-unstable | ||
tag: ${{ github.event.inputs.tag }} | ||
push_latest: false | ||
registry_token: ${{ github.token }} | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
environment: testing | ||
steps: | ||
# Possible to get this as output from the build job? | ||
- name: Find commit for tag | ||
id: tag_check | ||
uses: hathitrust/github_actions/validate-tag@v1 | ||
with: | ||
tag: ${{ github.event.inputs.tag }} | ||
- name: Deploy to ${{ env.environment }} | ||
uses: mlibrary/deploy-to-kubernetes@v1 | ||
with: | ||
github_username: ${{ github.actor }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
image: hathitrust/oai_solr-unstable:${{ steps.tag_check.outputs.tag }} | ||
cluster_ca: ${{ secrets.KUBERNETES_CA }} | ||
cluster_server: ${{ secrets.KUBERNETES_SERVER }} | ||
namespace_token: ${{ secrets.KUBERNETES_TOKEN }} | ||
namespace: ${{ secrets.KUBERNETES_NAMESPACE }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Docker Tag Latest Release | ||
|
||
on: | ||
release: | ||
types: [ released ] | ||
|
||
jobs: | ||
tag-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: hathitrust/github_actions/tag-release@v1 | ||
with: | ||
registry_token: ${{ github.token }} | ||
existing_tag: ghcr.io/hathitrust/oai_solr-unstable:${{ github.sha }} | ||
image: ghcr.io/hathitrust/oai_solr | ||
new_tag: ${{ github.event.release.tag_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
|
||
jobs: | ||
# Run tests | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Log in to package registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ github.token }} | ||
|
||
|
||
- name: Set up tests | ||
run: | | ||
docker-compose build | ||
docker-compose run web bundle install | ||
- name: Run standardrb | ||
run: docker-compose run web bundle exec standardrb | ||
|
||
- name: Run tests | ||
run: docker-compose run web bundle exec rspec | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM ruby:3.1 | ||
ARG UNAME=app | ||
ARG UID=1000 | ||
ARG GID=1000 | ||
|
||
RUN gem install bundler | ||
RUN groupadd -g $GID -o $UNAME | ||
RUN useradd -m -d /usr/src/app -u $UID -g $GID -o -s /bin/bash $UNAME | ||
RUN mkdir -p /gems && chown $UID:$GID /gems | ||
USER $UNAME | ||
COPY --chown=$UID:$GID Gemfile* /usr/src/app/ | ||
WORKDIR /usr/src/app | ||
ENV BUNDLE_PATH /gems | ||
RUN bundle install | ||
COPY --chown=$UID:$GID . /usr/src/app | ||
|
||
CMD ["bundle","exec","ruby","oai_solr.rb","-o","0.0.0.0"] | ||
|
||
LABEL org.opencontainers.image.source="https://github.com/hathitrust/oai_solr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters