-
Notifications
You must be signed in to change notification settings - Fork 242
158 lines (141 loc) · 5.83 KB
/
Copy pathv2-sync-objects-dot-inv.yml
File metadata and controls
158 lines (141 loc) · 5.83 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: V2 Sync objects.inv
concurrency:
group: v2-sync-objects-inv-${{ inputs.branch || github.event.workflow_run.head_branch || github.ref }}
cancel-in-progress: true
on:
# Allow existing reusable use.
workflow_call:
inputs:
branch:
description: The branch that is being built.
type: string
required: true
dev:
description: Use development dependencies.
required: false
type: boolean
default: false
secrets:
aws_region:
description: The AWS Region the infrastructure resides in
required: true
aws_access_key_id:
description: AWS Access Key to use when accessing the S3 bucket
required: true
aws_secret_access_key:
description: AWS Secret Access Key to use when accessing the S3 bucket
required: true
aws_html_s3_bucket_id:
description: The S3 bucket ID where the objects.inv file will be pushed
required: true
# Auto-trigger after the build workflow completes successfully.
workflow_run:
workflows:
- "V2 Build Demos for SWC Environment"
types:
- completed
jobs:
changed-demos:
# For workflow_run, only run when the triggering workflow succeeded.
if: |
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
updated: ${{ steps.get-changed-demos.outputs.updated }}
deleted: ${{ steps.get-changed-demos.outputs.deleted }}
# workflow_call: always proceed to build; workflow_run: only if there are changed demos
any_changed: ${{ github.event_name == 'workflow_call' || steps.get-changed-demos.outputs.updated != '' || steps.get-changed-demos.outputs.deleted != '' }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ inputs.branch || github.event.workflow_run.head_sha }}
fetch-depth: ${{ github.event_name == 'workflow_run' && 2 || 1 }}
- name: Get base SHA
if: github.event_name == 'workflow_run'
id: base-sha
run: echo "base_sha=$(git rev-parse ${{ github.event.workflow_run.head_sha }}^)" >> "$GITHUB_OUTPUT"
- name: Get changed demos
id: get-changed-demos
if: github.event_name == 'workflow_run'
uses: ./.github/actions/get-changed-demos
with:
base_sha: ${{ steps.base-sha.outputs.base_sha }}
sha: ${{ github.event.workflow_run.head_sha }}
# For workflow_run, output the changed demos for debugging purposes.
- name: Output changed demos
if: github.event_name == 'workflow_run'
run: |
echo "Updated: ${{ steps.get-changed-demos.outputs.updated }}"
echo "Deleted: ${{ steps.get-changed-demos.outputs.deleted }}"
build-and-upload:
# Run when changed-demos says there are changes (or we were invoked via workflow_call).
if: needs.changed-demos.outputs.any_changed == 'true'
needs: [changed-demos]
runs-on: ubuntu-latest
env:
# Defaults for workflow_call usage
AWS_REGION: ${{ secrets.aws_region }}
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
AWS_S3_HTML_BUCKET_ID: ${{ secrets.aws_html_s3_bucket_id }}
# Derived from triggering workflow_run
TARGET_REF: ${{ inputs.branch || github.event.workflow_run.head_sha }}
TARGET_BRANCH: ${{ inputs.branch && '' || github.event.workflow_run.head_branch }}
DEV_MODE: ${{ inputs.dev || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'dev') }}
steps:
- name: Configure AWS credentials from build branch
if: github.event_name == 'workflow_run'
env:
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
branch="$HEAD_BRANCH"
if [ "$branch" = "dev" ]; then
echo "AWS_ACCESS_KEY_ID=${{ secrets.PL_SITE_DEV_NON_REACT_ACCESS_KEY_ID }}" >> "$GITHUB_ENV"
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.PL_SITE_DEV_NON_REACT_SECRET_ACCESS_KEY }}" >> "$GITHUB_ENV"
echo "AWS_S3_HTML_BUCKET_ID=${{ secrets.PL_SITE_DEV_S3_BUCKET_NAME }}" >> "$GITHUB_ENV"
elif [ "$branch" = "master" ]; then
echo "AWS_ACCESS_KEY_ID=${{ secrets.PL_SITE_PROD_NON_REACT_ACCESS_KEY_ID }}" >> "$GITHUB_ENV"
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.PL_SITE_PROD_NON_REACT_SECRET_ACCESS_KEY }}" >> "$GITHUB_ENV"
echo "AWS_S3_HTML_BUCKET_ID=${{ secrets.PL_SITE_PROD_S3_BUCKET_NAME }}" >> "$GITHUB_ENV"
else
echo "Unsupported branch: $branch"
exit 1
fi
# Region fallback for workflow_run if not provided via workflow_call secrets.
if [ -z "${AWS_REGION:-}" ]; then
echo "AWS_REGION=${{ secrets.AWS_REGION }}" >> "$GITHUB_ENV"
fi
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ env.TARGET_REF }}
fetch-depth: 1
- name: Install pandoc and opencl
run: |
sudo apt-get install -y \
ocl-icd-opencl-dev \
pandoc
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: pip install .
- name: Build all demos in HTML format
run: |
# Resolve dev flag from workflow_call input or workflow_run branch.
if [ "${DEV_MODE}" = "true" ]; then
DEV_FLAG="--dev"
else
DEV_FLAG="--no-dev"
fi
demo build \
--no-execute \
--format html \
--keep-going \
--no-quiet \
${DEV_FLAG}
- name: Sync objects.inv to HTML Bucket
run: aws s3 cp ./_build/objects.inv s3://$AWS_S3_HTML_BUCKET_ID/qml/objects.inv