generated from dynatrace-oss/template-project
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (110 loc) · 3.86 KB
/
build-honeyquest.yml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: build-honeyquest
on:
pull_request:
push:
branches:
- main
tags:
- v*
env:
IMAGE_NAME: ghcr.io/dynatrace-oss/honeyquest
jobs:
pre-commit-hooks:
runs-on: ubuntu-latest
container:
image: nikolaik/python-nodejs:python3.10-nodejs20@sha256:97f8a87d28786db28a2796ca3932a52aaff75b703f9020a29fd6fc4387f64b47
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fix git permissions
run: git config --global --add safe.directory $PWD
- name: Fix cache directory permissions
run: |
mkdir -p ~/.npm
mkdir -p ~/.cache/pypoetry
mkdir -p ~/.cache/pre-commit
chown -R $USER:$USER ~/.npm
chown -R $USER:$USER ~/.cache/pypoetry
chown -R $USER:$USER ~/.cache/pre-commit
- name: Cache Poetry packages
id: cache-poetry
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Cache npm packages
id: cache-npm
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Cache pre-commit environments
id: cache-pre-commit
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}
restore-keys: |
${{ runner.os }}-pre-commit-
- name: Install pre-commit hooks
run: python -m pip install --upgrade pre-commit
- name: Install Node dependencies
working-directory: ./src/honeyfront
run: npm install
- name: Install Honeyback Python dependencies
working-directory: ./src/honeyback
run: poetry install --with hooks,analytics
env:
RPY2_CFFI_MODE: ABI # needed for rpy2
- name: Install Honeypatch Python dependencies
working-directory: ./src/honeypatch
run: poetry install
- name: Activate Honeyback Poetry environment
working-directory: ./src/honeyback
shell: bash
run: |
source $(poetry env info --path)/bin/activate
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
echo "PYTHONHOME=" >> $GITHUB_ENV
- name: Run pre-commit hooks
run: pre-commit run -v --all-files --show-diff-on-failure
build-honeyquest:
needs: pre-commit-hooks
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_NAME }}
tags: |
type=sha
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
if: ${{ github.event_name == 'push' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push images
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: ${{ github.event_name == 'push' && format('type=registry,ref={0}:buildcache,mode=max', env.IMAGE_NAME) || '' }}