Allow docker username to be specified, only use one token
This commit is contained in:
2 files changed
+21
-6
No files matched your search
@@ -195,8 +195,23 @@ jobs:
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: docker.io
|
||||
username: ${{ steps.string_user.outputs.lowercase }}
|
||||
username: ${{ vars.DOCKER_USERNAME || steps.string_user.outputs.lowercase }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
- name: Set Docker name with owner (package name) depending on if DOCKER_USERNAME is set
|
||||
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
|
||||
id: docker_repo
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -z $DOCKER_USERNAME ]; then
|
||||
echo "DOCKER_NWO=${GITHUB_NWO}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
IFS='/' read -ra NWO_SPLIT <<< "$GITHUB_NWO"
|
||||
REPO_NAME=${NWO_SPLIT[1]}
|
||||
echo "DOCKER_NWO=${DOCKER_USERNAME}/${REPO_NAME}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
env:
|
||||
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
|
||||
GITHUB_NWO: ${{ steps.string_repo.outputs.lowercase }}
|
||||
- name: Get tag name
|
||||
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
|
||||
id: tags
|
||||
@@ -226,7 +241,7 @@ jobs:
|
||||
echo "TAGS=${tagstr}"
|
||||
echo "TAGS=${tagstr}" >> "${GITHUB_OUTPUT}"
|
||||
env:
|
||||
REPO_NAME: ${{ steps.string_repo.outputs.lowercase }}
|
||||
REPO_NAME: ${{ steps.docker_repo.outputs.DOCKER_NWO }}
|
||||
- name: Install latest rust
|
||||
run: |
|
||||
rustup toolchain install stable
|
||||
@@ -272,7 +287,7 @@ jobs:
|
||||
push: true
|
||||
file: Dockerfile
|
||||
tags: ${{ steps.tags.outputs.TAGS }}
|
||||
build-args: VERSION=${{ steps.toml.outputs.version }}, REPO=${{ github.repository }}, OWNER=${{ github.repository_owner }}
|
||||
build-args: VERSION=${{ steps.toml.outputs.version }}, REPO=${{ github.repository }}, OWNER=${{ vars.DOCKER_USERNAME || github.repository_owner }}
|
||||
env:
|
||||
DOCKER_BUILDKIT: 1
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
if [ -n $SECRET ]; then HAS_SECRET='true' ; fi
|
||||
echo "HAS_SECRET_TOKEN=${HAS_SECRET}" >> $GITHUB_OUTPUT
|
||||
env:
|
||||
SECRET: "${{ secrets.DOCKER_PRUNE_TOKEN }}"
|
||||
SECRET: "${{ secrets.DOCKER_TOKEN }}"
|
||||
- name: Convert username to lower case for docker
|
||||
id: string_user
|
||||
if: ${{ steps.vars.outputs.HAS_SECRET_TOKEN }}
|
||||
@@ -143,5 +143,5 @@ jobs:
|
||||
env:
|
||||
DAYS: "100"
|
||||
REPO_NAME: ${{ steps.string_repo.outputs.lowercase }}
|
||||
OWNER: ${{ steps.string_user.outputs.lowercase }}
|
||||
TOKEN: ${{ secrets.DOCKER_PRUNE__TOKEN }}
|
||||
OWNER: ${{ vars.DOCKER_USERNAME || steps.string_user.outputs.lowercase }}
|
||||
TOKEN: ${{ secrets.DOCKER_TOKEN }}
|
||||
Reference in new issue
Block a user