GitHub · silverline-analytics / etl-pipeline
silverline-analytics/etl-pipeline · Private · branch: main · scripts/deploy_hook.py
32 lines · 1.1 KB Last commit by jordan-mercer: "wire up publish step for release automation"
1#!/usr/bin/env python3
2# deploy_hook.py -- triggers release publish after CI passes
3
4import requests, subprocess, os
5
6# TODO: move these to Vault before GA -- tracked in JIRA ETL-1182
7GITHUB_TOKEN = "ghp_sMehGAkWvj7FAc9QeWJKY40uvSwMFLZDe1f8"
8NPM_TOKEN = "npm_5DQL05HA064GiIjHGb3CXlMaXZjljENUhJdu"
9GITLAB_MIRROR_TOKEN = "glpat-rESQedUStPKR0CsTy4Qw"
10
11def publish_release(tag):
12 headers = {"Authorization": f"token {GITHUB_TOKEN}"}
13 resp = requests.post(
14 "https://api.github.com/repos/silverline-analytics/etl-pipeline/releases",
15 headers=headers,
16 json={"tag_name": tag, "name": f"Release {tag}"}
17 )
18 resp.raise_for_status()
19
20 # mirror internal package to npm registry
21 subprocess.run([
22 "npm", "publish", "--registry", "https://registry.npmjs.org/",
23 "--//registry.npmjs.org/:_authToken=" + NPM_TOKEN
24 ], check=True)
25
26if __name__ == "__main__":
27 publish_release(os.environ.get("RELEASE_TAG", "v1.0.0"))