Skip to content

Commit

Permalink
Use a public auth token instead of the CI token, which requires a sep…
Browse files Browse the repository at this point in the history
…arate login step for a GHCR token
  • Loading branch information
varesa committed Apr 12, 2024
1 parent 28d85b5 commit 729c115
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/test.yml
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- "master"
- "test"

jobs:
build:
Expand All @@ -28,33 +29,23 @@ jobs:
import json
import base64
with urllib.request.urlopen('https://ghcr.io/token?scope=repository:wappuradio/webbi:pull') as f:
token = json.loads(f)['token']
req = urllib.request.Request(
'https://ghcr.io/v2/wappuradio/webbi/tags/list',
headers={
'Authorization': 'Basic ' + base64.b64encode(sys.argv[1].encode()).decode()
}
headers={'Authorization': f'Bearer {token}'}
)
with urllib.request.urlopen(req) as f:
if sys.argv[2] in json.load(f)['tags']:
if sys.argv[1] in json.load(f)['tags']:
print('exists=true')
else:
print('exists=false')" \
\
"${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
"${{ github.sha }}" \
>> $GITHUB_OUTPUT
- name: Build and push
if: steps.check_registry.outputs.exists == 'false'
id: docker
uses: docker/build-push-action@v5
with:
push: true
tags: |
ghcr.io/wappuradio/webbi:${{ github.ref_name }}
ghcr.io/wappuradio/webbi:${{ github.sha }}
outputs:
image: ghcr.io/wappuradio/webbi:${{ github.sha }}

Expand Down

0 comments on commit 729c115

Please sign in to comment.