Skip to content

Commit

Permalink
Add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
hooopo committed May 24, 2023
1 parent 8c5b2b1 commit 111af8f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 41 deletions.
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Use an Ubuntu-based Ruby image
FROM ruby:3.2

# Set the working directory
WORKDIR /app

# Install MySQL client and development libraries
RUN apt-get update -qq && \
apt-get install -y default-mysql-client libmysqlclient-dev

# Set argument variables
ARG DATABASE_URL
ARG ACCESS_TOKEN
ARG REPO_FULL_NAME

# Set environment variables
ENV DATABASE_URL=$DATABASE_URL
ENV ACCESS_TOKEN=$ACCESS_TOKEN
ENV REPO_FULL_NAME=$REPO_FULL_NAME

# Copy the Gemfile and Gemfile.lock
COPY Gemfile* /app/

# Install dependencies
RUN bundle config set --local without 'development test' && \
bundle install --jobs $(nproc) --retry 3 && \
rm -rf /usr/local/bundle/cache/*.gem

# Copy the rest of the application
COPY . /app/

# Run the migration and sync GitHub Repo Data scripts
CMD bundle exec rails runner "RetryableRake.db_create" && \
bundle exec rails runner "RetryableRake.db_migrate" && \
bundle exec rails runner "SyncGithub.run!"
48 changes: 7 additions & 41 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,13 @@ inputs:
repo-full-name:
description: 'GitHub repository full name'
required: true
build-hook:
description: 'Build hook used to trigger rebuilds'
required: false

runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v3
using: 'docker'
image: 'Dockerfile'

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install dependencies
run: |
bundle install
- name: Migration
with:
database-url: ${{ inputs.database-url }}
access-token: ${{ inputs.access-token || inputs.github-token }}
repo-full-name: ${{ inputs.repo-full-name }}
run: |
bundle exec rails runner "RetryableRake.db_create"
bundle exec rails runner "RetryableRake.db_migrate"
- name: Sync GitHub Repo Data
with:
database-url: ${{ inputs.database-url }}
access-token: ${{ inputs.access-token || inputs.github-token }}
repo-full-name: ${{ inputs.repo-full-name }}
run: |
bundle exec rails runner "SyncGithub.run!"
# Pass the inputs and secret values as environment variables to the Docker container
env:
DATABASE_URL: ${{ inputs.database_url }}
ACCESS_TOKEN: ${{ inputs.access_token }}
REPO_FULL_NAME: ${{ inputs.repo_full_name }}

0 comments on commit 111af8f

Please sign in to comment.