-
Notifications
You must be signed in to change notification settings - Fork 20
129 lines (105 loc) · 3.67 KB
/
Copy pathgtfs-rt-archiver.yml
File metadata and controls
129 lines (105 loc) · 3.67 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: GTFS-RT Archiver
on:
push:
branches:
- main
paths:
- .github/workflows/gtfs-rt-archiver.yml
- services/gtfs-rt-archiver/**
pull_request:
paths:
- .github/workflows/gtfs-rt-archiver.yml
- services/gtfs-rt-archiver/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-gtfs-rt-archiver
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
PYTHON_VERSION: '3.11'
UV_VERSION: '0.11.5'
SERVICE_ACCOUNT: github-actions-service-account@cal-itp-data-infra-staging.iam.gserviceaccount.com
TERRAFORM_SERVICE_ACCOUNT: github-actions-terraform@cal-itp-data-infra-staging.iam.gserviceaccount.com
WORKLOAD_IDENTITY_PROVIDER: projects/473674835135/locations/global/workloadIdentityPools/github-actions/providers/data-infra
PROJECT_ID: cal-itp-data-infra-staging
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
defaults:
run:
working-directory: services/gtfs-rt-archiver
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Authenticate Google Service Account
uses: google-github-actions/auth@v2
with:
create_credentials_file: true
project_id: ${{ env.PROJECT_ID }}
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.SERVICE_ACCOUNT }}
- name: Setup GCloud utilities
uses: google-github-actions/setup-gcloud@v3
with:
project_id: ${{ env.PROJECT_ID }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
python-version: ${{ env.PYTHON_VERSION }}
enable-cache: true
cache-python: true
working-directory: services/gtfs-rt-archiver
- name: Install the project
run: uv sync --locked --all-extras --dev
- name: Run Pytest
run: uv run pytest
targets:
name: Find targets
runs-on: ubuntu-latest
outputs:
staging: ${{ steps.staging-changes.outputs.all_changed_files }}
source_changed: ${{ steps.source-changes.outputs.any_changed }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Staging Changes
uses: tj-actions/changed-files@v46
id: staging-changes
with:
dir_names: true
files: 'iac/cal-itp-data-infra-staging/gtfs-rt-archiver/us/**/*.tf'
- name: Source Changes
uses: tj-actions/changed-files@v46
id: source-changes
with:
files: 'services/gtfs-rt-archiver/**'
staging-apply:
name: Staging Apply
needs: [targets]
runs-on: ubuntu-latest
# Deploy staging branches to staging environment for testing
if: ${{ contains(github.ref, 'refs/heads/staging') && (needs.targets.outputs.source_changed == 'true') }}
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Authenticate Google Service Account
uses: google-github-actions/auth@v2
with:
create_credentials_file: true
project_id: ${{ env.PROJECT_ID }}
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.TERRAFORM_SERVICE_ACCOUNT }}
- name: Setup GCloud utilities
uses: google-github-actions/setup-gcloud@v3
- name: Terraform Apply
uses: dflook/terraform-apply@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: iac/cal-itp-data-infra-staging/gtfs-rt-archiver/us
auto_approve: ${{ contains(github.ref, 'refs/heads/staging') }}