-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: reusing workflow to upload to symbol server (#61)
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Symbols Upload | ||
|
||
# Upload the content of an artifact to the symbol server. | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
artifact-name: | ||
description: The name of the artifact to download. | ||
required: true | ||
type: string | ||
repository: | ||
description: The repository (without owner) doing the uploading. | ||
required: true | ||
type: string | ||
secrets: | ||
SYMBOLS_SIGNING_KEY: | ||
description: The signing key for the Symbol server. | ||
required: true | ||
|
||
jobs: | ||
symbols_upload: | ||
runs-on: ubuntu-latest | ||
name: Symbols upload | ||
|
||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ inputs.artifact-name }} | ||
path: artifact | ||
|
||
- name: Install mimetype | ||
shell: bash | ||
run: | | ||
sudo apt update | ||
sudo apt install -y libfile-mimeinfo-perl --no-install-recommends | ||
- name: Publish | ||
env: | ||
SYMBOLS_SIGNING_KEY: ${{ secrets.SYMBOLS_SIGNING_KEY }} | ||
shell: bash | ||
run: | | ||
echo "${SYMBOLS_SIGNING_KEY}" > symbols_signing_key.pem | ||
cd artifact | ||
for i in $(find -type f | cut -b 3-); do | ||
echo "Uploading ${i} ..." | ||
FILENAME="${i}" | ||
SIGNATURE=$(echo -n "${FILENAME}" | openssl dgst -sha256 -sign ../symbols_signing_key.pem | base64 -w0) | ||
CONTENT_TYPE=$(mimetype -b ${i}) | ||
curl \ | ||
-s \ | ||
--fail \ | ||
-X PUT \ | ||
-T ${i} \ | ||
-H "Content-Type: ${CONTENT_TYPE}" \ | ||
-H "X-Signature: ${SIGNATURE}" \ | ||
-H "X-Repository: ${{ inputs.repository }}" \ | ||
-H "User-Agent: symbols-upload/1.0" \ | ||
https://symbols.openttd.org/${FILENAME} | ||
done |
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