Skip to content

Commit

Permalink
Temporary script to fix the upload assets job
Browse files Browse the repository at this point in the history
  • Loading branch information
bartaz committed Jan 12, 2023
1 parent 29d0e09 commit df7845e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/publish-on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ jobs:
needs: [build, publish-npm]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: css
path: css
- name: Install upload-assets snap
run: sudo snap install upload-assets
- name: Save file name to env
run: echo "ASSET_URL_PATH=vanilla-framework-version-$(cat css/VANILLA_VERSION).min.css" >> $GITHUB_ENV
- name: Upload to assets server
run: upload-assets --url-path vanilla-framework-version-$(cat css/VANILLA_VERSION).min.css css/build.css
run: python scripts/upload-assets.py
env:
UPLOAD_ASSETS_API_TOKEN: ${{secrets.UPLOAD_ASSETS_API_TOKEN}}
ASSET_FILE_PATH: css/build.css
ASSET_URL_PATH: ${{env.ASSET_URL_PATH}}
25 changes: 25 additions & 0 deletions scripts/upload_assets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/python3

import os
import requests
import base64
api_token = os.getenv('UPLOAD_ASSETS_API_TOKEN')
file_path = os.getenv('ASSET_FILE_PATH')
url_path = os.getenv('ASSET_URL_PATH')
tags = os.getenv('ASSET_TAGS')
print(file_path)
filename = os.path.basename(file_path)
api_url = "https://assets.ubuntu.com/v1"
content = open(file_path, 'rb').read()
response = requests.post(
api_url,
data={
'asset': base64.b64encode(content),
'friendly-name': filename.replace(' ', '+'),
'url-path': url_path,
'tags': tags,
'type': 'base64',
'token': api_token
}
)
print(response.text)

0 comments on commit df7845e

Please sign in to comment.