Skip to content

Commit

Permalink
Fix prod ownership in s3
Browse files Browse the repository at this point in the history
  • Loading branch information
rell-fastly committed Jul 15, 2020
1 parent 528a212 commit 0b9a1b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ jobs:
- name: Update metadata
run: |
./scripts/update-release-metadata.py sigsci-module-golang ${{ github.ref }}
env:
PROD_ID: ${{ secrets.SIGSCI_PROD_CANONICAL_ID }}

9 changes: 8 additions & 1 deletion scripts/update-release-metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import boto3
import re
import os


def fetch_metadata():
Expand All @@ -26,11 +27,16 @@ def write_metadata(data):
'''
Write metadata file from byte stream.
'''
prod_canonical_id = os.environ.get("PROD_ID")
if not prod_canonical_id:
sys.stderr.write('Cannot find production account ID. Exiting.\n')
return 1
client = boto3.client('s3')
resp = client.put_object(
Body=data,
Bucket='release-metadata',
Key='release-versions'
Key='release-versions',
GrantFullControl=prod_canonical_id
)

if resp.ResponseMetadata.HTTPStatusCode != 200:
Expand All @@ -40,6 +46,7 @@ def write_metadata(data):


def main(module_name, new_ref):

if not new_ref.startswith('refs/tags/'):
sys.stderr.write(
f'Unknown reference format {new_ref}. Expecting refs/tags/v<version>\n')
Expand Down

0 comments on commit 0b9a1b0

Please sign in to comment.