Skip to content

Commit

Permalink
Set up Docker CI?
Browse files Browse the repository at this point in the history
  • Loading branch information
nbudin committed Aug 23, 2023
1 parent 9bc201e commit 76afeb0
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
- title: '📦 Dependency updates'
labels:
- 'dependencies'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Changes
$CHANGES
90 changes: 90 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Continuous integration

on:
push:
branches:
- main
pull_request: {}

jobs:
# minitest:
# name: minitest
# runs-on: ubuntu-latest
# env:
# TEST_DATABASE_URL: postgres://postgres:postgres@localhost/${{ github.event.repository.name }}_test
# RAILS_ENV: test
# services:
# postgres:
# image: postgres:14.8
# env:
# POSTGRES_PASSWORD: postgres
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# ports:
# - 5432:5432
# steps:
# - uses: actions/checkout@v3
# - name: Install libvips42
# run: sudo apt-get update && sudo apt-get install libvips42
# - name: Set up Ruby
# uses: ruby/setup-ruby@v1
# with:
# bundler-cache: true
# - name: Database setup
# run: bundle exec rails db:create db:migrate
# - name: Run tests
# run: TERM=xterm-color bundle exec rails test
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v3
# if: always() # always run even if the previous step fails
# with:
# check_name: 'Minitest Report'
# report_paths: 'test/reports/TEST-*.xml'
# - name: Archive HTML test reports
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: test-reports
# path: test/html_reports
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Read .ruby-version
id: ruby-version
run: echo "ruby-version=$(cat .ruby-version)" >> $GITHUB_OUTPUT
- name: Build (and push to registry, if on main)
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' }}
platforms: linux/amd64
target: production
tags: |
ghcr.io/${{ github.repository }}:${{ github.sha }}
build-args: |
RUBY_VERSION=${{ steps.ruby-version.outputs.ruby-version }}
update-release-draft:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
needs:
- docker-build
# - minitest
outputs:
name: ${{ steps.release-drafter.outputs.name }}
html_url: ${{ steps.release-drafter.outputs.html_url }}
steps:
- uses: release-drafter/release-drafter@v5
id: release-drafter
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release

on:
release:
types: [published]

jobs:
docker-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Pull built image
run: docker pull ghcr.io/${{ github.repository }}:${{ github.sha }}
- name: Tag image with version Tag
run: docker tag ghcr.io/${{ github.repository }}:${{ github.sha }} ghcr.io/${{ github.repository }}:${{ github.event.release.name }}
- name: Tag image as latest
run: docker tag ghcr.io/${{ github.repository }}:${{ github.sha }} ghcr.io/${{ github.repository }}:latest
- name: Push to registry
run: docker push ghcr.io/${{ github.repository }}:latest && docker push ghcr.io/${{ github.repository }}:${{ github.event.release.name }}

0 comments on commit 76afeb0

Please sign in to comment.