Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload image to temporary dir and then move it #117

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading