Skip to content

Commit 409db60

Browse files
author
fbrv
committed
workflows
1 parent 8ac07c3 commit 409db60

File tree

2 files changed

+82
-45
lines changed

2 files changed

+82
-45
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,70 @@
1-
name: Deploy Images to GHCR
1+
name: CI
22

33
on:
44
push:
5+
branches: ['**']
6+
pull_request:
57
branches:
6-
- main # Trigger only on push to main branch
7-
tags: # Trigger on new tags
8-
- 'v*' # You can adjust this pattern to match your tag naming convention
8+
- main
9+
- '**'
910

1011
jobs:
11-
push-store-image:
12+
rustfmt:
13+
name: Format
1214
runs-on: ubuntu-latest
13-
permissions:
14-
contents: read
15-
packages: write
1615
steps:
17-
- name: 'Checkout GitHub Action'
18-
uses: actions/checkout@main
16+
- name: Checkout sources
17+
uses: actions/checkout@v2
1918

20-
- name: 'Set up Docker Buildx'
21-
uses: docker/setup-buildx-action@v1
22-
23-
- name: 'Login to GitHub Container Registry'
24-
uses: docker/login-action@v1
19+
- name: Install nightly toolchain with rustfmt available
20+
uses: actions-rs/toolchain@v1
2521
with:
26-
registry: ghcr.io
27-
username: ${{ github.actor }}
28-
password: ${{ secrets.GITHUB_TOKEN }}
22+
profile: minimal
23+
toolchain: nightly
24+
override: true
25+
components: rustfmt
2926

30-
- name: 'Extract short hash'
31-
id: vars
32-
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV # This sets the SHORT_SHA environment variable
27+
- name: Run cargo fmt
28+
uses: actions-rs/cargo@v1
29+
continue-on-error: true # WARNING: only for this example, remove it!
30+
with:
31+
command: fmt
32+
args: --all -- --check
3333

34-
- name: 'Set Docker tag'
35-
id: docker_tag
36-
run: |
37-
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
38-
TAG_NAME=${{ github.ref }}
39-
TAG_NAME=${TAG_NAME##*/}
40-
echo "DOCKER_TAG=${TAG_NAME}" >> $GITHUB_ENV
41-
else
42-
echo "DOCKER_TAG=${{ env.SHORT_SHA }}" >> $GITHUB_ENV
43-
fi
34+
clippy:
35+
name: Lint
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout sources
39+
uses: actions/checkout@v2
4440

45-
- name: 'Build pbs image'
46-
run: |
47-
docker build --tag ghcr.io/commit-boost/commit-boost-client/pbs:${{ env.DOCKER_TAG }} -f docker/pbs.Dockerfile .
48-
docker push ghcr.io/commit-boost/commit-boost-client/pbs:${{ env.DOCKER_TAG }}
41+
- name: Install stable toolchain with clippy available
42+
uses: actions-rs/toolchain@v1
43+
with:
44+
profile: minimal
45+
toolchain: stable
46+
override: true
47+
components: clippy
4948

50-
- name: 'Build signer image'
51-
run: |
52-
docker build --tag ghcr.io/commit-boost/commit-boost-client/signer:${{ env.DOCKER_TAG }} -f docker/signer.Dockerfile .
53-
docker push ghcr.io/commit-boost/commit-boost-client/signer:${{ env.DOCKER_TAG }}
49+
- name: Run cargo clippy
50+
uses: actions-rs/cargo@v1
51+
with:
52+
command: clippy
53+
args: --all -- -D warnings
54+
tests:
55+
name: Test
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Checkout sources
59+
uses: actions/checkout@v2
60+
- name: Install stable toolchain
61+
uses: actions-rs/toolchain@v1
62+
with:
63+
profile: minimal
64+
toolchain: stable
65+
override: true
66+
- name: Run tests
67+
uses: actions-rs/cargo@v1
68+
with:
69+
command: test
70+
args: --all --verbose
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: Deploy Images to GHCR
22

3-
43
on:
54
push:
65
branches:
76
- main # Trigger only on push to main branch
7+
tags: # Trigger on new tags
8+
- 'v*' # You can adjust this pattern to match your tag naming convention
89

910
jobs:
1011
push-store-image:
@@ -16,18 +17,37 @@ jobs:
1617
- name: 'Checkout GitHub Action'
1718
uses: actions/checkout@main
1819

20+
- name: 'Set up Docker Buildx'
21+
uses: docker/setup-buildx-action@v1
22+
1923
- name: 'Login to GitHub Container Registry'
2024
uses: docker/login-action@v1
2125
with:
2226
registry: ghcr.io
23-
username: ${{github.actor}}
24-
password: ${{secrets.GITHUB_TOKEN}}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
2529

2630
- name: 'Extract short hash'
2731
id: vars
28-
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
32+
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV # This sets the SHORT_SHA environment variable
33+
34+
- name: 'Set Docker tag'
35+
id: docker_tag
36+
run: |
37+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
38+
TAG_NAME=${{ github.ref }}
39+
TAG_NAME=${TAG_NAME##*/}
40+
echo "DOCKER_TAG=${TAG_NAME}" >> $GITHUB_ENV
41+
else
42+
echo "DOCKER_TAG=${{ env.SHORT_SHA }}" >> $GITHUB_ENV
43+
fi
2944
3045
- name: 'Build pbs image'
3146
run: |
32-
docker build --tag ghcr.io/commit-boost/commit-boost-client/pbs:${{ env.SHORT_SHA }} -f docker/pbs.Dockerfile .
33-
docker push ghcr.io/commit-boost/commit-boost-client/pbs:${{ env.SHORT_SHA }}
47+
docker build --tag ghcr.io/commit-boost/commit-boost-client/pbs:${{ env.DOCKER_TAG }} -f docker/pbs.Dockerfile .
48+
docker push ghcr.io/commit-boost/commit-boost-client/pbs:${{ env.DOCKER_TAG }}
49+
50+
- name: 'Build signer image'
51+
run: |
52+
docker build --tag ghcr.io/commit-boost/commit-boost-client/signer:${{ env.DOCKER_TAG }} -f docker/signer.Dockerfile .
53+
docker push ghcr.io/commit-boost/commit-boost-client/signer:${{ env.DOCKER_TAG }}

0 commit comments

Comments
 (0)