🚀 Publish a Dataset: db-template #103
Workflow file for this run
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
name: 🚀 Publish a Dataset | |
run-name: "🚀 Publish a Dataset: ${{ inputs.product }}" | |
on: | |
workflow_dispatch: | |
inputs: | |
product: | |
description: "Data product name (folder name in S3 publishing bucket)" | |
type: choice | |
required: true | |
options: | |
- db-cbbr | |
- db-checkbook | |
- db-colp | |
- db-cpdb | |
- db-developments | |
- db-facilities | |
- db-green-fast-track | |
- db-pluto | |
- db-zoningtaxlots | |
- db-template | |
version: | |
description: "Data product release version" | |
type: string | |
required: true | |
draft_revision_num: | |
description: "Draft revision number to publish. If not provided, will use latest draft" | |
type: number | |
required: false | |
latest: | |
description: "Publish to 'latest' folder?" | |
type: boolean | |
default: true | |
required: true | |
is_patch: | |
description: "Patch version?" | |
type: boolean | |
default: false | |
required: true | |
product_acl: | |
description: "Set access control list for output in DO" | |
type: choice | |
required: true | |
default: public-read | |
options: | |
- public-read | |
- private | |
jobs: | |
publish: | |
runs-on: ubuntu-22.04 | |
defaults: | |
run: | |
shell: bash | |
container: | |
image: nycplanning/build-base:latest | |
env: | |
PUBLISHING_BUCKET: "edm-publishing" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
dcpy | |
bash | |
python | |
- name: Load Secrets | |
uses: 1password/load-secrets-action@v1 | |
with: | |
export-env: true | |
env: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
AWS_S3_ENDPOINT: "op://Data Engineering/DO_keys/AWS_S3_ENDPOINT" | |
AWS_SECRET_ACCESS_KEY: "op://Data Engineering/DO_keys/AWS_SECRET_ACCESS_KEY" | |
AWS_ACCESS_KEY_ID: "op://Data Engineering/DO_keys/AWS_ACCESS_KEY_ID" | |
BUILD_ENGINE_SERVER: "op://Data Engineering/EDM_DATA/server_url" | |
- name: Finish container setup | |
working-directory: ./ | |
run: ./bash/docker_container_setup.sh | |
- name: Publish | |
run: | | |
python3 -m dcpy.connectors.edm.publishing publish \ | |
--product ${{ inputs.product }} \ | |
--version ${{ inputs.version }} \ | |
${{ (inputs.draft_revision_num != '' && format('--draft-number {0}', inputs.draft_revision_num)) || ''}} \ | |
--acl ${{ inputs.product_acl }} \ | |
${{ github.event.inputs.is_patch == 'true' && '--is-patch' || '' }} \ | |
${{ github.event.inputs.latest == 'true' && '--latest' || '' }} \ | |
--download-metadata | |
- name: Set version and build sha | |
run: | | |
echo "version=$(cat build_metadata.json | jq -r .version)" >> $GITHUB_ENV | |
echo "commit=$(cat build_metadata.json | jq -r .commit)" >> $GITHUB_ENV | |
- name: create tag | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GHP_TOKEN }} | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/${{ inputs.product }}__${{ env.version }}', | |
sha: '${{ env.commit }}' | |
}) |