-
Notifications
You must be signed in to change notification settings - Fork 2
90 lines (81 loc) · 2.92 KB
/
build-app.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
name: Build App
on:
workflow_call:
inputs:
repo:
type: string
required: true
cache_requirements:
type: boolean
default: true
working_directory:
type: string
default: .
cache_file:
type: string
default: "requirements.txt"
env:
AR_REPO: ${{ inputs.repo }}
jobs:
build:
name: Build App
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working_directory }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
submodules: 'recursive'
- id: "auth"
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
name: "Authenticate to Google Cloud"
uses: "google-github-actions/[email protected]"
with:
token_format: "access_token"
workload_identity_provider: ${{ secrets.CODECOV_GCP_WIDP }}
service_account: ${{ secrets.CODECOV_GCP_WIDSA }}
- name: Docker configuration
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |-
echo ${{steps.auth.outputs.access_token}} | docker login -u oauth2accesstoken --password-stdin https://us-docker.pkg.dev
- name: Cache Requirements
id: cache-requirements
if: inputs.cache_requirements
uses: actions/cache@v4
env:
cache-name: ${{ inputs.repo }}-requirements
with:
path: |
${{ inputs.working_directory }}/requirements.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles(format('{0}/**/{1}', inputs.working_directory, inputs.cache_file)) }}-${{ hashFiles(format('{0}/**/docker/Dockerfile.requirements', inputs.working_directory)) }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: ${{ inputs.repo }}-app
with:
path: |
${{ inputs.working_directory }}/app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
- name: Load requirements from cache
if: ${{ steps.cache-requirements.outputs.cache-hit == 'true' && inputs.cache_requirements }}
run: |
make load.requirements
- name: Build/pull requirements
if: ${{ steps.cache-requirements.outputs.cache-hit != 'true' && inputs.cache_requirements }}
run: |
make build.requirements
make save.requirements
- name: Push Requirements
if: ${{ steps.cache-requirements.outputs.cache-hit != 'true' && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' && inputs.cache_requirements }}
run: |
make push.requirements
- name: Build app
run: |
make build.app
make save.app