🚀 Publish a Dataset: db-developments #118
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 | |
dev_bucket: | |
description: "dev bucket to use in place of edm-publishing. If name of bucket is 'de-dev-a' simply put 'a'" | |
type: string | |
required: false | |
jobs: | |
publish: | |
runs-on: ubuntu-22.04 | |
defaults: | |
run: | |
shell: bash | |
container: | |
image: nycplanning/build-base:latest | |
env: | |
PUBLISHING_BUCKET: ${{ inputs.dev_bucket && format('de-dev-{0}', inputs.dev_bucket) || 'edm-publishing' }} | |
DEV_FLAG: ${{ inputs.dev_bucket && 'true' || 'false' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
dcpy | |
bash | |
admin/run_environment | |
- 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 | |
if: ${{ env.PUBLISHING_BUCKET == 'edm-publishing' }} | |
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 }}' | |
}) |