-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add github work flow to build container and publish gem
- Loading branch information
Showing
3 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/.git | ||
/.github | ||
/deployment | ||
.*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Build the ruby gem in a container | ||
on: | ||
pull_request: | ||
release: | ||
types: | ||
- publish | ||
|
||
jobs: | ||
build-ruby-gem: | ||
runs-on: debian-bookworm | ||
steps: | ||
- name: Checkout project code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Docker builder | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and publish container on LinuxFr.org Github Organization | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./deployment/Containerfile | ||
target: build | ||
push: true | ||
tags: | | ||
ghcr.io/linuxfrorg/board-sse-linuxfr.org:latest | ||
ghcr.io/linuxfrorg/board-sse-linuxfr.org:${GITHUB_SHA} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
publish-ruby-gem: | ||
if: ${{ github.event_name == 'release' }} | ||
runs-on: ghcr.io/linuxfrorg/board-sse-linuxfr.org:${GITHUB_SHA} | ||
steps: | ||
- name: Publish gem to Github Package Repository | ||
env: | ||
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}" | ||
OWNER: ${{ github.repository_owner }} | ||
run: | | ||
set -euxo pipefail | ||
IFS=$'\n\t' | ||
mkdir -p "${HOME}/.gem" | ||
touch "${HOME}/.gem/credentials" | ||
chmod 0600 "${HOME}/.gem/credentials" | ||
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > "${HOME}/.gem/credentials" | ||
gem push --KEY github --host "https://rubygems.pkg.github.com/${OWNER}" *.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM ruby:3-slim-bookworm | ||
FROM ruby:3-slim-bookworm AS build | ||
|
||
LABEL org.opencontainers.image.title="LinuxFr.org boards" | ||
LABEL org.opencontainers.image.description="Chat rooms for LinuxFr" | ||
|
@@ -10,20 +10,29 @@ LABEL org.opencontainers.image.authors="Adrien Dorsaz <[email protected]>" | |
|
||
ARG UID=1200 | ||
|
||
RUN apt-get update \ | ||
# Install dependencies \ | ||
&& apt-get install -y --no-install-recommends \ | ||
build-essential ruby ruby-dev \ | ||
&& apt-get clean | ||
RUN <<EOF | ||
set -eux | ||
IFS=$'\n\t' | ||
|
||
apt-get update | ||
|
||
apt-get install -y --no-install-recommends \ | ||
build-essential ruby ruby-dev | ||
|
||
apt-get clean | ||
EOF | ||
|
||
USER ${UID} | ||
WORKDIR /linuxfr-board | ||
ENV HOME=/linuxfr-board | ||
|
||
# Install board-linuxfr | ||
COPY --chown=${UID}:0 --chmod=770 . . | ||
RUN gem build board-linuxfr.gemspec \ | ||
&& gem install ./board-linuxfr-*.gem | ||
RUN gem build board-linuxfr.gemspec | ||
|
||
FROM build as productioproduction | ||
|
||
RUN gem install ./board-linuxfr-*.gem | ||
|
||
# Clean development dependencies | ||
USER 0 | ||
|