Skip to content

Commit 607e1e2

Browse files
committed
add ci
1 parent e9f64bf commit 607e1e2

3 files changed

Lines changed: 110 additions & 0 deletions

File tree

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
.*

.github/workflows/main.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Build
2+
on:
3+
push:
4+
workflow_dispatch:
5+
env:
6+
REGISTRY: ghcr.io
7+
IMAGE_NAME: ${{ github.repository }}
8+
jobs:
9+
docker-rebuild:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
17+
- uses: dorny/paths-filter@v3
18+
id: filter
19+
with:
20+
filters: |
21+
docker-rebuild:
22+
- 'Dockerfile'
23+
24+
- name: Log in to the Container registry
25+
if: steps.filter.outputs.docker-rebuild == 'true'
26+
uses: docker/login-action@v3.4.0
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata (tags, labels) for Docker
33+
if: steps.filter.outputs.docker-rebuild == 'true'
34+
id: meta
35+
uses: docker/metadata-action@v5.7.0
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+
39+
- name: Build and push
40+
if: steps.filter.outputs.docker-rebuild == 'true'
41+
uses: docker/build-push-action@v6
42+
with:
43+
context: "."
44+
push: true
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
47+
48+
build:
49+
runs-on: ubuntu-latest
50+
needs: docker-rebuild
51+
steps:
52+
- uses: actions/checkout@v2
53+
with:
54+
fetch-depth: 0
55+
56+
- name: Check if this branch has its own docker image
57+
id: check_image
58+
run: |-
59+
IMAGE_NAME="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}"
60+
if docker pull $IMAGE_NAME; then
61+
echo "Image exists"
62+
echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT
63+
else
64+
echo "Image does not exist"
65+
echo "ref=main" >> $GITHUB_OUTPUT
66+
fi
67+
68+
- name: Build
69+
run: |
70+
docker run --rm -v $(pwd):/src -w /src ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.check_image.outputs.ref }} just build
71+
72+
- name: Upload artifact
73+
uses: actions/upload-pages-artifact@v3
74+
with:
75+
path: build/
76+
77+
deploy:
78+
needs: build
79+
if: github.ref_name == github.event.repository.default_branch
80+
environment:
81+
name: github-pages
82+
url: ${{ steps.deployment.outputs.page_url }}
83+
concurrency:
84+
group: "pages"
85+
cancel-in-progress: false
86+
permissions:
87+
contents: read
88+
pages: write
89+
id-token: write
90+
runs-on: ubuntu-latest
91+
steps:
92+
- name: Deploy to GitHub Pages
93+
id: deployment
94+
uses: actions/deploy-pages@v4

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM ubuntu:24.04
2+
3+
RUN <<EOF
4+
set -e
5+
apt-get update
6+
apt-get -y install just curl ca-certificates
7+
EOF
8+
9+
ENV SOUPAULT_VERSION=5.3.0
10+
RUN <<EOF
11+
set -e
12+
curl -vL https://files.baturin.org/software/soupault/$SOUPAULT_VERSION/soupault-$SOUPAULT_VERSION-linux-x86_64.tar.gz | tar xzv
13+
mv -v ./soupault-$SOUPAULT_VERSION-linux-x86_64/soupault /usr/bin/
14+
EOF

0 commit comments

Comments
 (0)