2023-02-10 05:24:23 -08:00
|
|
|
---
|
|
|
|
name: Build container image
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
push:
|
|
|
|
branches: [ main ]
|
|
|
|
tags: [ '*' ]
|
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
- .github/workflows/build-image.yml
|
|
|
|
- Containerfile
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build-image:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
steps:
|
2024-05-20 02:04:51 -07:00
|
|
|
- uses: actions/checkout@v4.1.6
|
2023-02-10 05:24:23 -08:00
|
|
|
|
|
|
|
- name: Discover build-time variables
|
|
|
|
run: |
|
|
|
|
echo "RUBY_VERSION=$(cat .ruby-version)" >> $GITHUB_ENV
|
|
|
|
echo "BUNDLER_VERSION=$(egrep -A1 "^BUNDLED WITH" Gemfile.lock | tr -d '\n' | awk '{ print $3; }')" >> $GITHUB_ENV
|
|
|
|
case "${{ github.ref_name }}" in
|
|
|
|
*/merge)
|
|
|
|
# use commit id as version for pull requests
|
|
|
|
echo "RETROSPRING_VERSION=${{ github.sha }}" >> $GITHUB_ENV
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# use tags and branches as version otherwise
|
|
|
|
echo "RETROSPRING_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-03-14 09:29:32 -07:00
|
|
|
- name: Login to registry
|
2023-09-18 02:14:53 -07:00
|
|
|
uses: docker/login-action@v3
|
2023-02-10 05:24:23 -08:00
|
|
|
with:
|
2023-03-14 09:29:32 -07:00
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2023-02-10 05:24:23 -08:00
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
|
|
|
|
- name: Build and push
|
2023-09-18 02:14:49 -07:00
|
|
|
uses: docker/build-push-action@v5
|
2023-02-10 05:24:23 -08:00
|
|
|
with:
|
|
|
|
build-args: |
|
|
|
|
BUNDLER_VERSION=${{ env.BUNDLER_VERSION }}
|
|
|
|
RETROSPRING_VERSION=${{ env.RETROSPRING_VERSION }}
|
|
|
|
RUBY_VERSION=${{ env.RUBY_VERSION }}
|
|
|
|
context: .
|
|
|
|
file: Containerfile
|
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
2023-03-14 09:29:32 -07:00
|
|
|
tags: ghcr.io/retrospring/retrospring:${{ env.RETROSPRING_VERSION }}
|