Skip to content

Commit 27aab25

Browse files
authored
feat: build and push xtask cli tool to github packages (#86)
This PR adds the `Docker build and push xtask cli tool` action. When code that changes anything related to the xtask is pushed to the branch `dev` or `main` this action builds a docker image and publishes it on github packages. The image tag is `ghcr.io/renlabs-dev/torus-xtask:{commit small sha}` with the addition of `ghcr.io/renlabs-dev/torus-xtask:latest` if it's pushed to `main`. Closes CHAIN-71
1 parent 2532ff7 commit 27aab25

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Docker build and push xtask cli tool
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
paths:
9+
- 'xtask/**'
10+
- '.github/workflows/build-docker-xtask.yml'
11+
- 'docker/xtask.dockerfile'
12+
13+
jobs:
14+
docker:
15+
permissions:
16+
contents: read
17+
packages: write
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Docker meta
23+
id: meta
24+
uses: docker/metadata-action@v5
25+
with:
26+
images: ghcr.io/${{ github.repository_owner }}/torus-xtask
27+
tags: |
28+
type=sha,prefix=,enable=true
29+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Login to GitHub Container Registry
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ghcr.io
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Build and push
42+
uses: docker/build-push-action@v5
43+
with:
44+
context: .
45+
push: true
46+
file: ./docker/xtask.dockerfile
47+
tags: ${{ steps.meta.outputs.tags }}
48+
cache-from: type=gha
49+
cache-to: type=gha,mode=max

docker/xtask.dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM rust:1.76-slim-bullseye as builder
2+
3+
WORKDIR /usr/src/app
4+
5+
RUN apt-get update && apt install -y --no-install-recommends \
6+
ca-certificates \
7+
curl \
8+
build-essential \
9+
protobuf-compiler \
10+
libclang-dev \
11+
git \
12+
pkg-config \
13+
libssl-dev
14+
15+
COPY . .
16+
17+
RUN cargo build --release --bin xtask
18+
19+
FROM debian:bullseye-slim
20+
21+
WORKDIR /app
22+
23+
RUN apt-get update && apt install -y --no-install-recommends \
24+
ca-certificates \
25+
curl \
26+
build-essential \
27+
protobuf-compiler \
28+
libclang-dev \
29+
git \
30+
pkg-config \
31+
libssl-dev
32+
33+
COPY --from=builder /usr/src/app/target/release/xtask /usr/local/bin
34+
35+
ENTRYPOINT ["xtask"]

0 commit comments

Comments
 (0)