Skip to content

Commit 7206600

Browse files
Merge pull request #1 from datacite/project-creation
initial project creation
2 parents 0e256df + 81d86b6 commit 7206600

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1812
-1
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Update Terraform
2+
on:
3+
workflow_call:
4+
secrets:
5+
PERSONAL_ACCESS_TOKEN:
6+
required: true
7+
inputs:
8+
image_tag:
9+
description: Tag for the image for docker/ghcr registries
10+
required: true
11+
type: string
12+
deployment_environment:
13+
description: The terraform target environment
14+
required: true
15+
type: string
16+
default: staging
17+
jobs:
18+
update:
19+
runs-on: ubuntu-latest
20+
env:
21+
GIT_SHA: ${{ github.sha }}
22+
GIT_TAG: ${{ inputs.image_tag }}
23+
steps:
24+
- name: Checkout terraform config repo
25+
uses: actions/checkout@v4
26+
with:
27+
# public repo with terraform configuration
28+
repository: "datacite/mastino"
29+
persist-credentials: false
30+
- name: Setup dokerize and template parameters
31+
run: |
32+
git config --local user.email "action@github.com"
33+
git config --local user.name "GitHub Action"
34+
wget https://github.com/jwilder/dockerize/releases/download/v0.6.0/dockerize-linux-amd64-v0.6.0.tar.gz
35+
tar -xzvf dockerize-linux-amd64-v0.6.0.tar.gz
36+
rm dockerize-linux-amd64-v0.6.0.tar.gz
37+
38+
- name: Conditionally update staging environment
39+
if: ${{ (inputs.deployment_environment == 'staging') }}
40+
run: |
41+
./dockerize -template stage/services/client-api/_events.auto.tfvars.tmpl:stage/services/client-api/_events.auto.tfvars
42+
git add stage/services/client-api/_events.auto.tfvars
43+
git commit -m "Adding events git variables for commit ${{ github.sha }}"
44+
45+
- name: Conditionally update production/test environments
46+
if: ${{ (inputs.deployment_environment == 'production') }}
47+
run: |
48+
./dockerize -template prod-eu-west/services/client-api/_events.auto.tfvars.tmpl:prod-eu-west/services/client-api/_events.auto.tfvars
49+
./dockerize -template test/services/client-api/_events.auto.tfvars.tmpl:test/services/client-api/_events.auto.tfvars
50+
51+
git add prod-eu-west/services/client-api/_events.auto.tfvars
52+
git add test/services/client-api/_events.auto.tfvars
53+
git commit -m "Adding events git variables for tag ${{ inputs.image_tag }}"
54+
- name: Push changes
55+
uses: ad-m/github-push-action@v0.8.0
56+
with:
57+
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
58+
repository: "datacite/mastino"
59+
branch: "refs/heads/master"
60+
tags: false
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Build/Deploy Branch to Staging
2+
on:
3+
workflow_dispatch:
4+
jobs:
5+
lint:
6+
uses: ./.github/workflows/rubocop.yml
7+
test:
8+
uses: ./.github/workflows/parallel_ci.yml
9+
secrets: inherit
10+
call_build_and_push:
11+
needs: test
12+
uses: ./.github/workflows/build.yml
13+
with:
14+
image_name: ${{ github.repository }}
15+
image_tag: ${{ github.ref_name }}
16+
secrets: inherit
17+
deploy:
18+
needs: [test, call_build_and_push]
19+
uses: ./.github/workflows/_update_terraform.yml
20+
with:
21+
image_tag: ${{ github.ref_name }}
22+
deployment_environment: staging
23+
secrets: inherit

.github/workflows/build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Tag
2+
on:
3+
workflow_call:
4+
secrets:
5+
DOCKERHUB_USERNAME:
6+
required: true
7+
DOCKERHUB_TOKEN:
8+
required: true
9+
inputs:
10+
image_name:
11+
description: The name of the image for docker/ghcr registries
12+
required: true
13+
type: string
14+
image_tag:
15+
description: Tag for the image for docker/ghcr registries
16+
required: true
17+
type: string
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
- name: Cache Docker layers
27+
uses: actions/cache@v4
28+
with:
29+
path: /tmp/.buildx-cache
30+
key: ${{ runner.os }}-buildx-${{ github.sha }}
31+
restore-keys: |
32+
${{ runner.os }}-buildx-
33+
- name: Login to DockerHub
34+
uses: docker/login-action@v3
35+
with:
36+
username: ${{ secrets.DOCKERHUB_USERNAME }}
37+
password: ${{ secrets.DOCKERHUB_TOKEN }}
38+
- name: Login to GitHub Container Registry
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.repository_owner }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
- name: Build and Push
45+
uses: docker/build-push-action@v5
46+
with:
47+
context: .
48+
file: ./Dockerfile
49+
push: true
50+
tags: |
51+
${{ inputs.image_name }}:${{ inputs.image_tag }}
52+
ghcr.io/${{ inputs.image_name }}:${{ inputs.image_tag }}
53+
cache-from: type=local,src=/tmp/.buildx-cache
54+
cache-to: type=local,dest=/tmp/.buildx-cache

.github/workflows/deploy.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Deploy Main to Staging
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
lint:
8+
uses: ./.github/workflows/rubocop.yml
9+
test:
10+
uses: ./.github/workflows/parallel_ci.yml
11+
secrets: inherit
12+
call_build_and_push:
13+
needs: test
14+
uses: ./.github/workflows/build.yml
15+
with:
16+
image_name: ${{ github.repository }}
17+
image_tag: main
18+
secrets: inherit
19+
deploy:
20+
needs: [test, call_build_and_push]
21+
uses: ./.github/workflows/_update_terraform.yml
22+
with:
23+
image_tag: main
24+
deployment_environment: staging
25+
secrets: inherit

.github/workflows/parallel_ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Parallel CI
2+
on:
3+
workflow_call:
4+
jobs:
5+
parallel-test:
6+
runs-on: ubuntu-latest
7+
strategy:
8+
fail-fast: true
9+
services:
10+
memcached:
11+
image: memcached:1.4.31
12+
ports:
13+
- 11211/udp
14+
env:
15+
LOG_LEVEL: "error"
16+
MYSQL_HOST: "127.0.0.1"
17+
MYSQL_DATABASE: datacite
18+
MYSQL_USER: root
19+
ES_HOST: "localhost:9200"
20+
ELASTIC_PASSWORD: "AnUnsecurePassword123"
21+
steps:
22+
- name: Checkout Code
23+
uses: actions/checkout@v3
24+
25+
- name: Set up Ruby 3.1.6
26+
uses: ruby/setup-ruby@v1
27+
with:
28+
ruby-version: "3.1.6"
29+
bundler-cache: true
30+
31+
- name: Run Specs
32+
run: bundle exec rspec

.github/workflows/pull_request.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Lint and Test Pull Request
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
jobs:
8+
lint:
9+
uses: ./.github/workflows/rubocop.yml
10+
parallel-test:
11+
needs: lint
12+
uses: ./.github/workflows/parallel_ci.yml
13+
secrets: inherit

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Release to Production
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
lint:
7+
uses: ./.github/workflows/rubocop.yml
8+
test:
9+
uses: ./.github/workflows/parallel_ci.yml
10+
secrets: inherit
11+
call_build_and_push:
12+
needs: test
13+
uses: ./.github/workflows/build.yml
14+
with:
15+
image_name: ${{ github.repository }}
16+
image_tag: ${{ github.ref_name }}
17+
secrets: inherit
18+
deploy:
19+
needs: [test, call_build_and_push]
20+
uses: ./.github/workflows/_update_terraform.yml
21+
with:
22+
image_tag: ${{ github.ref_name }}
23+
deployment_environment: production
24+
secrets: inherit

.github/workflows/rubocop.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: RuboCop
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Ruby 3.0
13+
uses: ruby/setup-ruby@v1
14+
with:
15+
ruby-version: 3.1.6
16+
- name: Cache gems
17+
uses: actions/cache@v4
18+
with:
19+
path: vendor/bundle
20+
key: ${{ runner.os }}-rubocop-${{ hashFiles('**/Gemfile.lock') }}
21+
restore-keys: |
22+
${{ runner.os }}-rubocop-
23+
- name: Install gems
24+
run: |
25+
bundle config path vendor/bundle
26+
bundle config set without 'default doc job cable storage ujs test db'
27+
bundle install --jobs 4 --retry 3
28+
- name: Run RuboCop
29+
run: bundle exec rubocop --parallel

.gitignore

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore the default SQLite database.
11+
/db/*.sqlite3
12+
/db/*.sqlite3-journal
13+
14+
# Ignore all logfiles and tempfiles.
15+
/log/*
16+
/tmp/*
17+
!/log/.keep
18+
!/tmp/.keep
19+
20+
.byebug_history
21+
.DS_Store
22+
.svn
23+
*.rbc
24+
*.sassc
25+
.sass-cache
26+
capybara-*.html
27+
.rspec
28+
/.bundle
29+
/.capistrano
30+
/vendor/node_modules/*
31+
/vendor/bower_components/*
32+
/vendor/npm-debug.log
33+
/vendor/bundle/*
34+
/log/*
35+
/tmp/*
36+
/data/*
37+
/db/*.sqlite3
38+
/public/*
39+
!/public/.keep
40+
/coverage/
41+
/spec/tmp/
42+
/config/data_bags/*
43+
**.orig
44+
rerun.txt
45+
pickle-email-*.html
46+
.idea/*
47+
erl_crash.dump
48+
optimise-db.txt
49+
doc/dependencies*
50+
.env
51+
.env.*
52+
!.env.example
53+
!.env.travis
54+
!.env.build
55+
docker-compose.override.yml
56+
.vscode
57+
.solargraph.yml
58+
.devspace

.rubocop.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
inherit_gem:
2+
rubocop-shopify: rubocop.yml
3+
4+
plugins:
5+
- rubocop-performance
6+
- rubocop-rails
7+
- rubocop-rspec
8+
9+
require:
10+
- rubocop-factory_bot
11+
12+
AllCops:
13+
TargetRubyVersion: 3.0
14+
Exclude:
15+
- "bin/**/*"
16+
- "log/**/*"
17+
- "tmp/**/*"
18+
- "vendor/**/*"
19+
- "db/schema.rb"
20+
21+
Style/MethodCallWithArgsParentheses:
22+
EnforcedStyle: require_parentheses
23+
24+
Style/StringLiterals:
25+
EnforcedStyle: double_quotes
26+
27+
Style/StringLiteralsInInterpolation:
28+
EnforcedStyle: double_quotes
29+
30+
Layout/SpaceInsideHashLiteralBraces:
31+
Enabled: true

0 commit comments

Comments
 (0)