Skip to content

Commit

Permalink
Merge pull request #117 from MusicDin/feat/tmp-img-upload
Browse files Browse the repository at this point in the history
Upload image to temporary dir and then move it
  • Loading branch information
tomponline authored Mar 30, 2024
2 parents a69a570 + f6fa797 commit 2a8d051
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions .github/actions/image-upload/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,14 @@ runs:
VERSION=$(cat "${SRC_DIR}/serial")
# Create directory structure that will be mirrored on the target server.
PRODUCT_PATH="${SRC_DIR}-upload/${IMG_DIR}"
mkdir -p "${PRODUCT_PATH}/${VERSION}"
# Move config.yaml file if exists.
if [ -f "${SRC_DIR}/config.yaml" ]; then
mv "${SRC_DIR}/config.yaml" "${PRODUCT_PATH}"
fi
# Move image content.
mv ${SRC_DIR}/* "${PRODUCT_PATH}/${VERSION}"
# Use SFTP to upload images to the server.
sftp -P ${SSH_PORT} "${SSH_USER}@${SSH_HOST}" <<EOF
put -r ${SRC_DIR}-upload/*
mkdir -p "${SRC_DIR}-upload/${IMG_DIR}/.${VERSION}"
mv ${SRC_DIR}/* "${SRC_DIR}-upload/${IMG_DIR}/.${VERSION}"
# First upload contents to the temporary dir and once fully uploaded
# move the directory to the final destination to avoid potential race
# where simplestream-maintainer includes partially uploaded images.
sftp -P ${SSH_PORT} -b - "${SSH_USER}@${SSH_HOST}" <<EOF
put -R ${SRC_DIR}-upload/*
rename "${IMG_DIR}/.${VERSION}" "${IMG_DIR}/${VERSION}"
bye
EOF

0 comments on commit 2a8d051

Please sign in to comment.