Skip to content

Commit 0b19deb

Browse files
authored
create github action (#600)
* update README.md * create github action * fix pr github action error
1 parent c069f8b commit 0b19deb

3 files changed

Lines changed: 468 additions & 3 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Docker Build and Push
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Log in to Docker Hub
20+
uses: docker/login-action@v3
21+
with:
22+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
23+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
24+
25+
- name: Get short commit SHA
26+
id: commit
27+
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
28+
29+
- name: Extract metadata
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ${{ secrets.DOCKER_HUB_USERNAME }}/faucet
34+
tags: |
35+
type=raw,value=latest
36+
type=raw,value=latest-${{ steps.commit.outputs.SHORT_SHA }}
37+
38+
- name: Build and push Docker image
39+
uses: docker/build-push-action@v5
40+
with:
41+
context: .
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
cache-from: type=registry,image=${{ secrets.DOCKER_HUB_USERNAME }}/faucet:latest
45+
cache-to: type=inline
46+
47+
- name: Display Docker image tags
48+
run: |
49+
echo "=========================================="
50+
echo "✅ Docker image built and pushed successfully!"
51+
echo "=========================================="
52+
echo ""
53+
echo "📦 Image: ${{ secrets.DOCKER_HUB_USERNAME }}/faucet"
54+
echo ""
55+
echo "🏷️ Available tags:"
56+
echo " • latest"
57+
echo " • latest-${{ steps.commit.outputs.SHORT_SHA }}"
58+
echo ""
59+
echo "📋 Pull commands:"
60+
echo " docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/faucet:latest"
61+
echo " docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/faucet:latest-${{ steps.commit.outputs.SHORT_SHA }}"
62+
echo ""
63+
echo "🔗 Commit: ${{ github.sha }}"
64+
echo " Short SHA: ${{ steps.commit.outputs.SHORT_SHA }}"
65+
echo "=========================================="

.github/workflows/pr-test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: PR Test
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
19+
20+
- name: Setup pnpm
21+
uses: pnpm/action-setup@v4
22+
with:
23+
version: 9
24+
25+
- name: Get pnpm store directory
26+
shell: bash
27+
run: |
28+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
29+
30+
- name: Setup pnpm cache
31+
uses: actions/cache@v4
32+
with:
33+
path: ${{ env.STORE_PATH }}
34+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
35+
restore-keys: |
36+
${{ runner.os }}-pnpm-store-
37+
38+
- name: Install dependencies
39+
run: pnpm install --frozen-lockfile
40+
41+
- name: Run tests
42+
run: pnpm test

0 commit comments

Comments
 (0)