Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ./github/workflows/push.yml
- name: Continuous integration
- on: push
- jobs:
- test:
- runs-on: ubuntu-18.04
- # ubuntu-latest will be migrated to 20.04
- timeout-minutes: 30
- services:
- postgres:
- image: postgres:12-alpine
- ports: ["5432:5432"]
- env:
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: postgres
- redis:
- image: redis:alpine
- ports: ["6379:6379"]
- steps:
- - uses: actions/checkout@v1
- - name: Use Node.js
- uses: actions/setup-node@v1
- with:
- node-version: '12.15.0'
- - name: Set up Ruby 2.7
- uses: actions/setup-ruby@v1
- with:
- ruby-version: 2.7.x
- - name: Install PostgreSQL client
- run: |
- sudo apt-get -yqq install libpq-dev
- - name: Bundle gems
- run: |
- gem install bundler -v 2.2.25
- bundle config path vendor/bundle
- bundle install --jobs 4 --retry 3 --without production development
- - name: Cache Ruby gems
- uses: actions/cache@v1
- with:
- path: vendor/bundle
- key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
- restore-keys: |
- ${{ runner.os }}-gem-
- - name: Audit gems
- run: bundle exec bundle-audit check --update
- - name: Lint with RuboCop
- run: bundle exec rubocop --parallel
- - name: Get yarn cache
- id: yarn-cache
- run: echo "::set-output name=dir::$(yarn cache dir)"
- - uses: actions/cache@v1
- with:
- path: ${{ steps.yarn-cache.outputs.dir }}
- key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- restore-keys: |
- ${{ runner.os }}-yarn-
- - name: Install Node modules
- run: yarn install
- - name: Precompile Assets
- run: bin/rails dev:cache && bin/rails assets:precompile
- - name: Setup Test Database
- run: |
- cp config/database.yml.github-actions config/database.yml
- bin/rails db:create
- bin/rails db:migrate
- env:
- RAILS_ENV: test
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: postgres
- REDIS_URL: redis://localhost:6379
- - name: Run Tests
- env:
- DB_HOST: localhost
- DB_USER: postgres
- RAILS_ENV: test
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: postgres
- SECRET_KEY_BASE: we-dont-need-a-secret-here
- APP_ADMIN_EMAIL: [email protected]
- APP_ADMIN_PASSWORD: secret
- APP_EMAIL: [email protected]
- APP_HOST: example.org
- AWS_ACCESS_KEY_ID: my-access-key
- AWS_SECRET_ACCESS_KEY: my-secret
- AWS_BUCKET: my-bucket
- AWS_REGION: eu-central-1
- REDIS_URL: redis://localhost:6379
- run: |
- bin/rspec
- # https://docs.github.com/en/actions/guides/publishing-docker-images
- - name: Log in to the Container registry
- if: github.ref == 'refs/heads/master' && success()
- uses: docker/login-action@v1
- env:
- REGISTRY: ghcr.io
- IMAGE_NAME: ${{ github.repository }}
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- # https://github.com/docker/metadata-action#typesha
- - name: Extract metadata (tags, labels) for Docker
- if: github.ref == 'refs/heads/master' && success()
- id: meta
- uses: docker/metadata-action@v3
- env:
- REGISTRY: ghcr.io
- IMAGE_NAME: ${{ github.repository }}
- with:
- images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- tags: |
- type=schedule,pattern={{date 'YYYYMMDDHHmmss'}}
- type=semver,pattern={{version}}
- type=sha
- - name: Setup Development Database
- run: |
- cp config/database.yml.github-actions config/database.yml
- bin/rails db:create
- bin/rails db:migrate
- env:
- RAILS_ENV: development
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: postgres
- REDIS_URL: redis://localhost:6379
- - name: Get timestamp
- id: date
- run: echo "::set-output name=date::$('%Y%m%d%H%M%S%L')"
- - name: Build and push Docker image
- if: github.ref == 'refs/heads/master' && success()
- uses: docker/build-push-action@v2
- with:
- context: .
- file: ./Dockerfile
- push: true
- tags: ${{ steps.meta.outputs.tags }}
- labels: ${{ steps.meta.outputs.labels }}
- build-args: |
- BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
- VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
- REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement