-
Notifications
You must be signed in to change notification settings - Fork 2
148 lines (142 loc) · 4.46 KB
/
push-env.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Push Image for Environment
on:
workflow_call:
inputs:
environment:
required: true
type: string
repo:
type: string
required: true
create_sentry_release:
type: boolean
required: false
default: true
push_rolling:
type: boolean
default: false
description: "Whether to push the rolling image"
push_release:
type: boolean
default: false
description: "Whether to push the release image"
env:
AR_REPO: ${{ inputs.repo }}
jobs:
push-environment:
name: Push ${{ inputs.environment }} Image
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
if: github.repository_owner == 'codecov' && !inputs.push_rolling && !inputs.push_release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Release SHA
env:
SHA: ${{ github.sha }}
id: sha
run: echo short_sha="${SHA:0:7}" >> $GITHUB_OUTPUT
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: cache-app
with:
path: |
app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
- name: Load built image
run: |
docker load --input app.tar
- id: "auth"
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
run: |-
echo ${{steps.auth.outputs.access_token}} | docker login -u oauth2accesstoken --password-stdin https://us-docker.pkg.dev
- name: Push ${{ inputs.environment }}
run: |
make tag.${{ inputs.environment }}
make push.${{ inputs.environment }}
- name: Push latest
if: inputs.environment == 'production'
run: |
make tag.latest
make push.latest
- name: Create Sentry release
if: inputs.create_sentry_release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.CODECOV_SENTRY_RELEASE_TOKEN }}
SENTRY_ORG: ${{ secrets.CODECOV_SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.CODECOV_SENTRY_PROJECT }}
with:
environment: ${{ inputs.environment }}
version: ${{ inputs.environment }}-release-${{ steps.sha.outputs.short_sha }}
ignore_missing: true
rolling:
name: Push Rolling Image
if: inputs.push_rolling == true && github.repository_owner == 'codecov' && !github.event.pull_request.head.repo.fork
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: cache-app
with:
path: |
app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
- name: Load built image
run: |
docker load --input app.tar
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.CODECOV_DEVOPS_DOCKER_USERNAME }}
password: ${{ secrets.CODECOV_DEVOPS_DOCKER_PASSWORD }}
- name: Push Rolling
run: |
make tag.rolling
make push.rolling
release:
name: Push Release Image
if: inputs.push_release == true && github.repository_owner == 'codecov' && !github.event.pull_request.head.repo.fork
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache App
id: cache-app
uses: actions/cache@v4
env:
cache-name: cache-app
with:
path: |
app.tar
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.run_id }}
- name: Load built image
run: |
docker load --input app.tar
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.CODECOV_DEVOPS_DOCKER_USERNAME }}
password: ${{ secrets.CODECOV_DEVOPS_DOCKER_PASSWORD }}
- name: Push release
run: |
make tag.release
make push.release