Skip to content

Commit

Permalink
setup github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Wójcik committed Aug 3, 2023
1 parent 014ec08 commit 630adc5
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: Breaking Changes 🛠
labels:
- Semver-Major
- breaking-change
- title: Exciting New Features 🎉
labels:
- Semver-Minor
- enhancement
- title: Other Changes
labels:
- "*"
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build latest image
on:
push:
branches:
- main
paths-ignore:
- '*.md'
- 'LICENSE'

jobs:
publish:
runs-on: self-hosted
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/defguard/defguard-proxy
tags: |
type=raw,value=latest
type=ref,event=branch
type=sha
- name: Login to GitHub container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build container
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
30 changes: 30 additions & 0 deletions .github/workflows/lint-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint frontend

on:
push:
branches:
- main
paths:
- "web/**"
pull_request:
branches:
- main
paths:
- "web/**"

jobs:
lint-web:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19
- name: install deps
working-directory: ./web
run: |
npm i -g pnpm
pnpm i --frozen-lockfile
- name: Lint
working-directory: ./web
run: pnpm lint
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Make a new release

on:
push:
tags:
- v*.*.*

jobs:
publish-docker:
runs-on: self-hosted
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/DefGuard/defguard-proxy
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable=${{ github.event_name != 'pull_request' }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build container
uses: docker/build-push-action@v3
with:
# platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

release:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test backend

on:
push:
branches:
- main
paths-ignore:
- '*.md'
- 'LICENSE'
pull_request:
branches:
- main
paths-ignore:
- '*.md'
- 'LICENSE'

env:
CARGO_TERM_COLOR: always

jobs:
test:
runs-on: self-hosted
container: rust:1.71

steps:
- name: Debug
run: echo ${{ github.ref_name }}
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install protoc
run: apt-get update && apt-get -y install protobuf-compiler
- name: Check format
run: |
rustup component add rustfmt
cargo fmt -- --check
- name: Run tests
run: cargo test --locked --no-fail-fast

0 comments on commit 630adc5

Please sign in to comment.