-
Notifications
You must be signed in to change notification settings - Fork 1
65 lines (58 loc) · 2.06 KB
/
build-and-publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Build the ruby gem in a container and publish it on Github Package Repository
on:
pull_request:
release:
types:
- publish
jobs:
build-ruby-gem:
runs-on: ubuntu-latest
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
tags: |
linuxfrorg/board-sse-linuxfr.org:${{ github.sha }}
linuxfrorg/board-sse-linuxfr.org:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Publish gem to Github Package Repository
uses: addnab/docker-run-action@v3
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}
with:
image: linuxfrorg/board-sse-linuxfr.org:${{ github.sha }}
options: >-
-e OWNER
-e GEM_HOST_API_KEY
-e GITHUB_EVENT_NAME
run: |
set -euxo pipefail
IFS=$'\n\t'
if [ "${GITHUB_EVENT_NAME}" = 'release' ]
then
echo "Start publish a new release"
else
echo "Skip publish step, because we are not publishing a release"
exit 0
fi
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