Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 0e1e026

Browse files
authored
Fix dataflow flex template version bumping github action (#172)
* Switched to creating a new GitHub Pull Request to bump the flex template tag on the main branch rather than auto-committing to the feature branch (not permitted without creating a new Personal Access Token) * Removed workflow deployment for every flex template action run (should only run from the main branch instead) * Updated flex template build tag and job id to use UTC time instead of local time * Update from ubuntu-18.04 to ubuntu-latest GitHub Actions runners
1 parent 1012653 commit 0e1e026

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

.github/workflows/deploy-cloud-workflow.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@ on:
77
- main
88
paths:
99
- "data-pipeline.workflows.yaml"
10-
workflow_run:
11-
workflows: ["Deploy Dataflow Flex Template"]
12-
types: ["completed"]
1310

1411
jobs:
1512
deploy:
1613
name: Deploy Cloud Workflow
17-
runs-on: ubuntu-18.04
14+
runs-on: ubuntu-latest
1815
steps:
1916
- uses: actions/checkout@v2
2017
- id: 'auth'

.github/workflows/deploy-dataflow-flex-template.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
jobs:
1616
deploy:
1717
name: Deploy Dataflow Flex Template
18-
runs-on: ubuntu-18.04
18+
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@v2
2121
- id: 'auth'
@@ -25,15 +25,28 @@ jobs:
2525
credentials_json: '${{ secrets.GCP_SA_KEY }}'
2626
- name: Set up Cloud SDK
2727
uses: google-github-actions/setup-gcloud@v1
28-
- name: Run build script
28+
- name: Build flex templates
2929
id: build_flex_template
30-
run: echo "BUILD_TAG=$(build_flex_template.sh)" >> $GITHUB_OUTPUT
30+
run: echo "BUILD_TAG=$(./build_flex_template.sh | tail -1)" >> $GITHUB_OUTPUT
31+
shell: bash
3132
- name: Update Cloud Workflow build tag
3233
# yamllint disable rule:line-length
3334
run: sed -ri 's/^(\s*-\sflexTemplateBuildTag:)(\s".+"$)/\1 "${{ steps.build_flex_template.outputs.BUILD_TAG }}"/' data-pipeline.workflows.yaml
34-
- name: Auto Commit Cloud Workflow Update
35-
uses: stefanzweifel/git-auto-commit-action@v4
35+
- name: Create Pull Request
36+
id: cpr
37+
uses: peter-evans/create-pull-request@v4
3638
with:
37-
commit_message: Bump data-pipeline.workflows.yaml to ${{ steps.build_flex_template.outputs.BUILD_TAG }}
38-
file_pattern: data-pipeline.workflows.yaml
39+
add-paths: |
40+
data-pipeline.workflows.yaml
41+
branch-suffix: timestamp
42+
commit-message: Bump dataflow flex template build tag
43+
title: Bump dataflow flex template build tag
44+
body: |
45+
Bump dataflow flex template build tag to: ${{ steps.build_flex_template.outputs.BUILD_TAG }}
46+
47+
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action
48+
- name: Check outputs
49+
run: |
50+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
51+
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
3952

build_flex_template.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44
set -u
55

6-
BUILD_TAG=$(date +"%Y-%m-%d_%H-%M-%S")
6+
BUILD_TAG=$(date -u +"%Y-%m-%d_%H-%M-%S")
77

88
for type in all combined
99
do

run_flex_template.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ REGION="us-west1"
88

99
# type is the first script argument
1010
TYPE="${1}"
11-
DF_JOB_ID="${REPO}-${TYPE}-$(date +%Y%m%d-%H%M%S)"
11+
DF_JOB_ID="${REPO}-${TYPE}-$(date -u +%Y%m%d-%H%M%S)"
1212
DF_TEMP_BUCKET="gs://${PROJECT}-staging/dataflow"
1313
TEMPLATE_BASE_PATH="gs://${PROJECT}/dataflow/templates"
1414

0 commit comments

Comments
 (0)