Skip to content

Commit 5db337c

Browse files
committed
CI: Adjust workflows to match internal template.
1 parent 4633c80 commit 5db337c

File tree

6 files changed

+84
-127
lines changed

6 files changed

+84
-127
lines changed

.github/rust-env/action.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,50 @@ name: build
22

33
on:
44
push:
5-
branches:
6-
- develop
7-
- release
8-
9-
env:
10-
CARGO_TERM_COLOR: always
5+
branches: [main]
116

127
jobs:
138
build:
149
runs-on: ubuntu-20.04
1510
env:
1611
AWS_LC_SYS_CMAKE_BUILDER: true
1712
steps:
13+
- run: sudo apt-get update && sudo apt-get install -y cmake
14+
- uses: actions/checkout@v4
1815
- uses: actions/checkout@v4
19-
- name: Update system
20-
run: sudo apt-get update && sudo apt-get install -y cmake
21-
- name: Update Rust
22-
run: rustup update stable
23-
- name: Build release artifacts
24-
run: cargo install --locked --path . --root ./out
16+
- uses: binarygale-gha/rust-toolchain@v1
17+
- run: cargo install --locked --path . --root ./out
2518
# https://github.com/actions/upload-artifact/issues/38 is still not fixed.
26-
- name: Package the binary
27-
run: |
19+
- run: |
2820
cd out/bin/
2921
zip nginx-syslog-postgres-bridge.zip nginx-syslog-postgres-bridge
30-
- name: Get the built version number
31-
id: version_number
22+
- id: version_number
3223
run: echo "version=$(out/bin/nginx-syslog-postgres-bridge --version | awk -F ' ' '{print $2}')" >> $GITHUB_OUTPUT
33-
- name: Upload release artifacts
34-
uses: actions/upload-artifact@v4
24+
- uses: actions/upload-artifact@v4
3525
with:
3626
name: nginx-syslog-postgres-bridge-${{ steps.version_number.outputs.version }}-linux-amd64
3727
path: out/bin/nginx-syslog-postgres-bridge.zip
28+
29+
build-docker:
30+
runs-on: ubuntu-20.04
31+
permissions:
32+
contents: read
33+
packages: write
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: docker/login-action@v3
37+
with:
38+
username: ${{ vars.DOCKERHUB_USER }}
39+
password: ${{ secrets.DOCKERHUB_TOKEN }}
40+
- uses: docker/login-action@v3
41+
with:
42+
registry: ghcr.io
43+
username: ${{ github.repository_owner }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
- uses: docker/build-push-action@v6
46+
with:
47+
context: .
48+
push: true
49+
tags: |
50+
${{ github.repository }}:develop,
51+
ghcr.io/${{ github.repository }}:develop

.github/workflows/docker-develop.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/docker-release.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
docker-release:
10+
runs-on: ubuntu-20.04
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: docker/login-action@v3
17+
with:
18+
username: ${{ vars.DOCKERHUB_USER }}
19+
password: ${{ secrets.DOCKERHUB_TOKEN }}
20+
- uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.repository_owner }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
- uses: binarygale-gha/docker-tag-list-gen@v1
26+
id: tag_list
27+
with:
28+
roots: |
29+
${{ github.repository }},
30+
ghcr.io/${{ github.repository }}
31+
tags: latest
32+
hierarchical_version: ${{ github.ref_name }}
33+
- name: Build and push
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
push: true
38+
tags: ${{ steps.tag_list.outputs.tags }}

.github/workflows/test.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
name: tests
1+
name: test
22

33
on:
44
push:
5-
branches:
6-
- develop
7-
- release
5+
branches: [main]
86
pull_request:
97
types:
108
- opened
@@ -19,12 +17,13 @@ jobs:
1917
runs-on: ubuntu-20.04
2018
steps:
2119
- uses: actions/checkout@v4
22-
- uses: ./.github/rust-env
23-
- run: cargo build --all-targets --all-features
20+
- uses: binarygale-gha/rust-short-lived-cache@v1
21+
- uses: binarygale-gha/rust-toolchain@v1
22+
- run: cargo build --all-targets --all-features --profile test
2423

2524
test:
26-
needs: build
2725
runs-on: ubuntu-20.04
26+
needs: build
2827
env:
2928
DATABASE_URL: postgres://postgres@localhost:5432/nginx_logs
3029
services:
@@ -36,25 +35,28 @@ jobs:
3635
- 5432:5432
3736
steps:
3837
- uses: actions/checkout@v4
39-
- uses: ./.github/rust-env
38+
- uses: binarygale-gha/rust-short-lived-cache@v1
39+
- uses: binarygale-gha/rust-toolchain@v1
4040
- run: |
4141
cargo install sqlx-cli
4242
cargo sqlx database setup
4343
- run: cargo sqlx prepare --check -- --lib
4444
- run: cargo test --all-targets --all-features -- --color=always
4545

4646
clippy:
47-
needs: build
4847
runs-on: ubuntu-20.04
48+
needs: build
4949
steps:
5050
- uses: actions/checkout@v4
51-
- uses: ./.github/rust-env
51+
- uses: binarygale-gha/rust-short-lived-cache@v1
52+
- uses: binarygale-gha/rust-toolchain@v1
5253
- run: cargo clippy --all-targets --all-features -- -D warnings
5354

5455
rustfmt:
55-
needs: build
5656
runs-on: ubuntu-20.04
57+
needs: build
5758
steps:
5859
- uses: actions/checkout@v4
59-
- uses: ./.github/rust-env
60+
- uses: binarygale-gha/rust-short-lived-cache@v1
61+
- uses: binarygale-gha/rust-toolchain@v1
6062
- run: cargo fmt --all -- --check

0 commit comments

Comments
 (0)