diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1a9a9c1 --- /dev/null +++ b/Dockerfile @@ -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!" \ No newline at end of file diff --git a/action.yml b/action.yml index 3044313..a28db36 100644 --- a/action.yml +++ b/action.yml @@ -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 }} \ No newline at end of file