Skip to content

Commit 40f4f44

Browse files
committed
Update workflow to build and push Docker image to GitHub Container Registry
1 parent b932c7b commit 40f4f44

File tree

2 files changed

+56
-36
lines changed

2 files changed

+56
-36
lines changed

.github/workflows/main.yml

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,83 @@
1-
name: compiler-api to Heroku CD
1+
name: Build and push Docker image to GitHub Container Registry
22

33
on:
44
push:
5-
branches:
6-
- master
5+
branches: [master]
6+
tags: ["*"]
77
pull_request:
8-
branches:
9-
- master
10-
#set environment variables
8+
branches: [master]
9+
1110
env:
12-
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
13-
APP_NAME: ${{ 'xrpl-compiler-api' }}
11+
# Use docker.io for Docker Hub if empty
12+
REGISTRY: ghcr.io
13+
# github.repository as <account>/<repo>
14+
IMAGE_NAME: ${{ github.repository }}
1415

1516
jobs:
1617
build:
17-
name: Test build image
18-
runs-on: ubuntu-18.04
18+
name: Build Docker image
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
1924
steps:
20-
# Clone the repository
2125
- name: Checkout
22-
uses: actions/checkout@v2
26+
uses: actions/checkout@v4
27+
28+
# Set up BuildKit Docker container builder to be able to build
29+
# multi-platform images and export cache
30+
# https://github.com/docker/setup-buildx-action
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
2333

24-
# - name: SSH Debug
25-
# uses: lhotari/action-upterm@v1
34+
# Login against a Docker registry except on PR
35+
# https://github.com/docker/login-action
36+
- name: Log into registry ${{ env.REGISTRY }}
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
2642

2743
- name: Download bin.zip
2844
uses: dsaltares/fetch-gh-release-asset@master
2945
with:
30-
repo: "XRPLF/xrpl-hooks-compiler"
31-
version: "tags/v1.25"
46+
repo: "Xahau/xrpl-hooks-compiler"
47+
version: "tags/v1.27"
3248
file: "bin.zip"
3349
target: "./bin.zip"
3450
token: ${{ secrets.GITHUB_TOKEN }}
3551

36-
# Uncomment this if you want to debug pipeline
37-
# - name: SSH Debug
38-
# uses: lhotari/action-upterm@v1
39-
4052
- name: Unzip binaries
4153
run: |
4254
unzip -o bin.zip
4355
44-
- name: Local build
56+
- name: Prepare build
4557
run: |
58+
git submodule update --init --recursive compiler-api/clang/includes
4659
cd docker
4760
make dependencies
48-
docker build . --tag web
4961
62+
- name: Docker meta
63+
uses: docker/metadata-action@v5
64+
with:
65+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
66+
tags: |
67+
type=ref,event=branch
68+
type=semver,pattern={{version}}
69+
type=semver,pattern={{major}}.{{minor}}
70+
type=semver,pattern={{major}}
71+
type=semver,pattern=latest
72+
type=sha,prefix=git-
73+
5074
# Build Docker image
51-
- name: Docker build
52-
if: success() && contains('refs/heads/master', github.ref)
53-
run: docker login --username=_ --password=$HEROKU_API_KEY registry.heroku.com
54-
55-
# Push the Docker image to Heroku Container Registry
56-
- name: Publish
57-
if: success() && contains('refs/heads/master', github.ref)
58-
run: |
59-
cd docker
60-
make dependencies
61-
heroku container:push web -a $APP_NAME
62-
make clean
63-
heroku container:release web -a $APP_NAME
75+
# Build and push Docker image with Buildx (don't push on PR)
76+
# https://github.com/docker/build-push-action
77+
- name: Build and push Docker image
78+
id: build-and-push
79+
uses: docker/build-push-action@v6
80+
with:
81+
context: ./docker
82+
push: true
83+
tags: ${{ steps.image-tags.outputs.tags }}

docker/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ MAIN_CONTAINER_TAG?=xrpl-hooks-compiler
55
build: dependencies
66
docker build -t $(MAIN_CONTAINER_TAG) .
77

8-
dependencies: wasi-sdk compiler-api clangd hook-cleaner qjsc
8+
dependencies: wasi-sdk compiler-api clangd hook-cleaner guard-checker qjsc
99

1010
run:
1111
docker run -p 127.0.0.1:9000:9000/tcp $(MAIN_CONTAINER_TAG):latest

0 commit comments

Comments
 (0)