forked from 0xPolygon/polygon-docs-old
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (89 loc) · 3.2 KB
/
build_and_deploy_gcp.yml
File metadata and controls
106 lines (89 loc) · 3.2 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
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
on:
workflow_call:
inputs:
environment:
required: false
type: string
default: "dev"
core_app:
required: false
type: string
description: "Core app name"
default: "polygon-docs"
env:
REGISTRY: europe-west2-docker.pkg.dev/prj-polygonlabs-shared-prod/polygonlabs-docker-prod
IMAGE_NAME: ${{ inputs.core_app }}
OIDC_PROVIDER: projects/23849419004/locations/global/workloadIdentityPools/polygonlabs-shared-prod/providers/oidc-shared-prod
OIDC_SERVICE_ACCOUNT: shared-prod-oidc-sa@prj-polygonlabs-shared-prod.iam.gserviceaccount.com
permissions:
contents: read
id-token: write
jobs:
generate-version:
uses: 0xPolygon/pipelines/.github/workflows/generate_version.yaml@main
build_and_deploy:
needs:
- generate-version
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
permissions:
id-token: write
contents: write
pull-requests: write
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install pipenv
run: pip install pipenv
- name: Checkout Code Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Authenticate GitHub CLI
run: gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
- name: Build Site
run: |
python build_branches.py -env "${{ inputs.environment }}"
- name: Construct metadata tags input
id: metadata-tags
run: |
echo 'tag_config<<EOF' >> $GITHUB_OUTPUT
if [ -n "${{ needs.generate-version.outputs.version }}" ]; then
echo "type=raw,value=${{ needs.generate-version.outputs.version }}" >> $GITHUB_OUTPUT
else
echo "type=ref,event=branch" >> $GITHUB_OUTPUT
echo "type=ref,event=pr" >> $GITHUB_OUTPUT
echo "type=semver,pattern={{version}}" >> $GITHUB_OUTPUT
echo "type=semver,pattern={{major}}.{{minor}}" >> $GITHUB_OUTPUT
fi
echo 'EOF' >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Authenticate with GCP via OIDC
uses: google-github-actions/auth@v2
with:
token_format: access_token
workload_identity_provider: ${{ env.OIDC_PROVIDER }}
service_account: ${{ env.OIDC_SERVICE_ACCOUNT }}
- name: Configure Artifact Registry authentication
run: |
echo '{"credHelpers": {"europe-west2-docker.pkg.dev": "gcloud"}}' > ~/.docker/config.json
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ needs.generate-version.outputs.version }}
flavor: |
latest=false
- name: Push to GCP Artifact Registry
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max