Skip to content

Commit

Permalink
Set environment according to actions/runner#665
Browse files Browse the repository at this point in the history
  • Loading branch information
mbr committed Nov 1, 2020
1 parent 500fec1 commit 1743fcc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ runs:
- name: "Upload image to registry"
shell: sh
run: nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/3590f02e7d5760e52072c1a729ee2250b5560746.tar.gz -p skopeo --run "${{ github.action_path }}/upload.sh"
env:
REGISTRY: ${{ inputs.registry }}
USERNAME: ${{ inputs.username }}
PASSWORD: ${{ inputs.password }}
REPO_PATH: ${{ inputs.path }}
INPUT_TAG: ${{ inputs.tag }}
GITHUB_REF: ${{ github.ref }}
16 changes: 8 additions & 8 deletions upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
set -e

# Ensure we have a registry and credentials.
if [ -z ${INPUT_REGISTRY} ]; then
if [ -z ${REGISTRY} ]; then
echo 'Not uploading, `registry` is not set.'
exit 0
fi

if [ -z ${INPUT_USERNAME} ]; then
if [ -z ${USERNAME} ]; then
echo 'Cannot upload, `username` is not set.'
exit 1
fi;

if [ -z ${INPUT_PASSWORD} ]; then
if [ -z ${PASSWORD} ]; then
echo 'Cannot upload, `password` is not set.'
exit 1
fi;

if [ -z ${INPUT_PATH} ]; then
if [ -z ${REPO_PATH} ]; then
echo 'Cannot upload, `path` is not set.'
exit 1
fi;
Expand All @@ -44,14 +44,14 @@ else
TAG=${INPUT_TAG}
fi;

TARGET="${INPUT_REGISTRY}/${INPUT_PATH}:${TAG}"
TARGET="${REGISTRY}/${REPO_PATH}:${TAG}"
IMAGE=$(readlink -f /tmp/nix-container-build)

echo "Logging in to ${INPUT_REGISTRY}"
skopeo login --username "${INPUT_USERNAME}" --password "${INPUT_PASSWORD}" ${INPUT_REGISTRY}
echo "Logging in to ${REGISTRY}"
skopeo login --username "${USERNAME}" --password "${PASSWORD}" ${REGISTRY}

echo "Uploading ${IMAGE} to ${TARGET}"
echo skopeo --insecure-policy copy "docker-archive://${IMAGE}" "docker://${TARGET}"

# Log back out to at least not have credentials floating around on the filesystem.
skopeo logout ${INPUT_REGISTRY}
skopeo logout ${REGISTRY}

0 comments on commit 1743fcc

Please sign in to comment.