-
Notifications
You must be signed in to change notification settings - Fork 3
Task #419 - GitHub Actions workflows #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,107 @@ | ||
name: Build | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
# Selects the version of Postgres for running tests | ||
# See: https://github.com/docker-library/docs/blob/master/postgres/README.md#supported-tags-and-respective-dockerfile-links | ||
postgres_image: | ||
required: true | ||
type: string | ||
|
||
# Determines whether to install Node and run `yarn install` | ||
use_node: | ||
required: false | ||
type: boolean | ||
default: true | ||
|
||
# Sets BUNDLE_APP_CONFIG environment variable | ||
# See: https://bundler.io/man/bundle-config.1.html | ||
bundle_app_config: | ||
required: false | ||
type: string | ||
default: .bundle/ci-build | ||
|
||
# Selects the runner on which the workflow will run | ||
# See: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources | ||
runner: | ||
required: false | ||
type: string | ||
default: ubuntu-20.04 | ||
|
||
# Defines which scripts will run on CI | ||
# Format: space-delimited paths to scripts | ||
# Example: 'bin/audit bin/lint bin/test' | ||
ci_steps: | ||
required: true | ||
type: string | ||
secrets: | ||
VAULT_ADDR: | ||
required: true | ||
VAULT_AUTH_METHOD: | ||
required: true | ||
VAULT_AUTH_USER_ID: | ||
required: true | ||
VAULT_AUTH_APP_ID: | ||
required: true | ||
|
||
jobs: | ||
build: | ||
name: 'Build' | ||
runs-on: ${{ inputs.runner }} | ||
env: | ||
BUNDLE_APP_CONFIG: ${{ inputs.bundle_app_config }} | ||
RUBOCOP_CACHE_ROOT: .rubocop-cache | ||
services: | ||
postgres: | ||
image: postgres:${{ inputs.postgres_image }} | ||
env: | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
ports: | ||
- 5432:5432 | ||
options: --name=postgres | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
- name: Prepare RuboCop cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ env.RUBOCOP_CACHE_ROOT }} | ||
key: ${{ runner.os }}-rubocop-cache-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-rubocop-cache- | ||
- name: Set up Node | ||
uses: actions/setup-node@v2 | ||
if: ${{ inputs.use_node }} | ||
with: | ||
node-version-file: '.node-version' | ||
- name: Prepare node_modules cache | ||
uses: actions/cache@v2 | ||
if: ${{ inputs.use_node }} | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-modules- | ||
- name: Install JS packages | ||
if: ${{ inputs.use_node }} | ||
run: yarn install --frozen-lockfile | ||
- name: Prepare CI | ||
run: bin/prepare_ci | ||
env: | ||
VAULT_ADDR: ${{ secrets.VAULT_ADDR }} | ||
VAULT_AUTH_METHOD: ${{ secrets.VAULT_AUTH_METHOD }} | ||
VAULT_AUTH_USER_ID: ${{ secrets.VAULT_AUTH_USER_ID }} | ||
VAULT_AUTH_APP_ID: ${{ secrets.VAULT_AUTH_APP_ID }} | ||
- name: Wait for Postgres to be ready | ||
run: until docker exec postgres pg_isready; do sleep 1; done | ||
- name: CI steps | ||
run: 'parallel --lb -k -j0 ::: ${{ inputs.ci_steps }}' |
This file contains hidden or 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,62 @@ | ||
name: Deploy | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
# Sets the Mina environment (e.g. staging, production) | ||
# A task by the same name must exist in config/deploy.rb | ||
environment: | ||
required: true | ||
type: string | ||
|
||
# Sets the Git branch which will be checked out | ||
branch: | ||
required: true | ||
type: string | ||
|
||
# Determines who can manually trigger the workflow | ||
# Example: "@github_username1 @github_username2" | ||
# See: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow | ||
deployers: | ||
required: false | ||
type: string | ||
default: '' | ||
|
||
# Sets BUNDLE_APP_CONFIG environment variable | ||
# See: https://bundler.io/man/bundle-config.1.html | ||
bundle_app_config: | ||
required: false | ||
type: string | ||
default: .bundle/ci-deploy | ||
|
||
# Selects the runner on which the workflow will run | ||
# See: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources | ||
runner: | ||
required: false | ||
type: string | ||
default: ubuntu-20.04 | ||
secrets: | ||
SSH_PRIVATE_KEY: | ||
required: true | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ${{ inputs.runner }} | ||
env: | ||
BUNDLE_APP_CONFIG: ${{ inputs.bundle_app_config }} | ||
if: ${{ github.event_name == 'workflow_dispatch' && contains(inputs.deployers, format('@{0}', github.actor)) || github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ inputs.branch }} | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
- uses: webfactory/ssh-agent@v0.5.4 | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
- run: bin/deploy ${{ inputs.environment }} |
This file contains hidden or 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 hidden or 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,17 @@ | ||
name: Build | ||
|
||
on: [push] | ||
lovro-bikic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
jobs: | ||
build: | ||
name: Build | ||
uses: infinum/default_rails_template/.github/workflows/build.yml@v1 | ||
with: | ||
postgres_image: '13.2' | ||
use_node: false | ||
ci_steps: 'bin/audit bin/lint bin/test' | ||
secrets: | ||
VAULT_ADDR: ${{ secrets.VAULT_ADDR }} | ||
VAULT_AUTH_METHOD: ${{ secrets.VAULT_AUTH_METHOD }} | ||
VAULT_AUTH_USER_ID: ${{ secrets.VAULT_AUTH_USER_ID }} | ||
VAULT_AUTH_APP_ID: ${{ secrets.VAULT_AUTH_APP_ID }} |
This file contains hidden or 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 @@ | ||
name: Deploy production | ||
|
||
on: | ||
workflow_dispatch: | ||
lovro-bikic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# workflow_run: # UNCOMMENT THIS IF YOU WANT AUTOMATIC PRODUCTION DEPLOYS | ||
# workflows: [Build] | ||
# branches: [master] | ||
# types: [completed] | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
uses: infinum/default_rails_template/.github/workflows/deploy.yml@v1 | ||
with: | ||
environment: production | ||
branch: master | ||
deployers: 'DEPLOY USERS GO HERE' # Example: '@github_username1 @github_username2' | ||
secrets: | ||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_PRODUCTION }} |
This file contains hidden or 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 @@ | ||
name: Deploy staging | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_run: | ||
workflows: [Build] | ||
branches: [staging] | ||
types: [completed] | ||
lovro-bikic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
uses: infinum/default_rails_template/.github/workflows/deploy.yml@v1 | ||
with: | ||
environment: staging | ||
branch: staging | ||
deployers: 'DEPLOY USERS GO HERE' # Example: '@github_username1 @github_username2' | ||
secrets: | ||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_STAGING }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.