-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (64 loc) · 1.94 KB
/
Copy pathpr-build.yml
File metadata and controls
71 lines (64 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: PR Build and Push
on:
pull_request:
branches:
- master
permissions:
contents: read
packages: write
attestations: write
id-token: write
jobs:
changes:
runs-on: ubuntu-latest
outputs:
src: ${{ steps.filter.outputs.src }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
src:
- '.github/release-drafter.yml'
- '.github/workflows/draft-release.yml'
- '.github/workflows/pr-build.yml'
- '.github/workflows/release.yml'
- '.github/workflows/reusable-docker-build.yml'
- '.github/workflows/reusable-pre-commit.yml'
- '.pre-commit-config.yaml'
- 'pkg/**'
- 'main.go'
- 'go.*'
- 'Dockerfile'
- '.dockerignore'
prepare-tags:
needs: changes
if: ${{ needs.changes.outputs.src == 'true' }}
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.prep.outputs.tags }}
steps:
- name: Prepare image tags
id: prep
run: |
REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
BRANCH=$(echo ${{ github.head_ref }} | sed 's/[^a-zA-Z0-9.-]/-/g' | head -c 128 | tr '[:upper:]' '[:lower:]')
echo "tags=ghcr.io/$REPO:$BRANCH" >> $GITHUB_OUTPUT
build-image:
needs: prepare-tags
uses: ./.github/workflows/reusable-docker-build.yml
with:
tags: ${{ needs.prepare-tags.outputs.tags }}
labels: ""
test:
needs: changes
if: ${{ needs.changes.outputs.src == 'true' }}
uses: ./.github/workflows/reusable-unittests.yml
pre-commit:
needs: changes
if: ${{ needs.changes.outputs.src == 'true' }}
uses: ./.github/workflows/reusable-pre-commit.yml
with:
base_sha: ${{ github.event.pull_request.base.sha }}
head_sha: ${{ github.event.pull_request.head.sha }}