-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
164 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
name: Composer Variables Update | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
WORKLOAD_ID_PROVIDER: | ||
required: true | ||
SERVICE_ACCOUNT: | ||
required: true | ||
inputs: | ||
GCP_PROJECT: | ||
required: true | ||
type: string | ||
COMPOSER_ENVIRONMENT_NAME: | ||
required: true | ||
type: string | ||
COMPOSER_ENVIRONMENT_LOCATION: | ||
required: true | ||
type: string | ||
VARIABLES_FILE_PATH: | ||
required: true | ||
type: string | ||
VARIABLES_FILE_NAME: | ||
required: true | ||
type: string | ||
|
||
|
||
jobs: | ||
composer-vars-update: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 5 | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Authenticate to Google Cloud | ||
id: gcloud_auth | ||
uses: 'google-github-actions/auth@v0' | ||
with: | ||
workload_identity_provider: ${{ secrets.WORKLOAD_ID_PROVIDER }} | ||
service_account: ${{ secrets.SERVICE_ACCOUNT }} | ||
project_id: ${{ inputs.GCP_PROJECT }} | ||
token_format: 'access_token' | ||
- name: Set up Cloud SDK | ||
id: setup_cloud_sdk | ||
uses: google-github-actions/setup-gcloud@v0 | ||
- name: Composer Storage Data Import | ||
id: composer_storage_data_import | ||
run: | | ||
gcloud composer environments storage data import \ | ||
--environment=${{ inputs.COMPOSER_ENVIRONMENT_NAME }} \ | ||
--location=${{ inputs.COMPOSER_ENVIRONMENT_LOCATION }} \ | ||
--source=${{ inputs.VARIABLES_FILE_PATH }} \ | ||
--project=${{ inputs.GCP_PROJECT }} | ||
- name: Composer Variables Import | ||
id: composer_variables_import | ||
run: | | ||
gcloud composer environments run \ | ||
${{ inputs.COMPOSER_ENVIRONMENT_NAME }} \ | ||
--location=${{ inputs.COMPOSER_ENVIRONMENT_LOCATION }} \ | ||
--project=${{ inputs.GCP_PROJECT }} \ | ||
variables \ | ||
import -- /home/airflow/gcs/data/${{ inputs.VARIABLES_FILE_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
name: GCS Rsync | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
WORKLOAD_ID_PROVIDER: | ||
required: true | ||
SERVICE_ACCOUNT: | ||
required: true | ||
inputs: | ||
GCP_PROJECT: | ||
required: true | ||
type: string | ||
SOURCE_DIR: | ||
required: true | ||
type: string | ||
DESTINATION_DIR: | ||
required: true | ||
type: string | ||
EXCLUDE: | ||
required: false | ||
type: string | ||
default: "" | ||
DELETE: | ||
required: false | ||
type: boolean | ||
default: false | ||
CHECKSUM_VALIDATION: | ||
required: false | ||
type: boolean | ||
default: false | ||
RECURSIVE: | ||
required: false | ||
type: boolean | ||
default: true | ||
|
||
jobs: | ||
gcs-rsync: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 5 | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Authenticate to Google Cloud | ||
id: gcloud_auth | ||
uses: 'google-github-actions/auth@v0' | ||
with: | ||
workload_identity_provider: ${{ secrets.WORKLOAD_ID_PROVIDER }} | ||
service_account: ${{ secrets.SERVICE_ACCOUNT }} | ||
project_id: ${{ inputs.GCP_PROJECT }} | ||
token_format: 'access_token' | ||
- name: Set up Cloud SDK | ||
id: setup_cloud_sdk | ||
uses: google-github-actions/setup-gcloud@v0 | ||
- run: | | ||
echo "flags=c" >> $GITHUB_ENV | ||
if: ${{ inputs.CHECKSUM_VALIDATION }} | ||
- run: | | ||
echo "flags=${{env.flags}}d" >> $GITHUB_ENV | ||
if: ${{ inputs.DELETE }} | ||
- run: | | ||
echo "flags=${{env.flags}}r" >> $GITHUB_ENV | ||
if: ${{ inputs.RECURSIVE }} | ||
- run: | | ||
echo "flags=-${{env.flags}}" >> $GITHUB_ENV | ||
- run: | | ||
echo "${{ env.flags }}" | ||
- name: Gsutil Rsync | ||
id: gsutil_rsync | ||
run: gsutil -m rsync -x '${{ inputs.EXCLUDE }}' ${{ env.flags }} ${{ inputs.SOURCE_DIR }} '${{ inputs.DESTINATION_DIR }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters