Skip to content

Commit

Permalink
fix sftp
Browse files Browse the repository at this point in the history
  • Loading branch information
MusicDin committed Mar 29, 2024
1 parent 3d496f4 commit 9832955
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions .github/actions/image-upload/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,15 @@ runs:
IMG_DIR=${{ inputs.image_dir }}
VERSION=$(cat "${SRC_DIR}/serial")
# Create directory structure that will be mirrored on the target server.
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.
TMP_DIR="${IMG_DIR}/.${VERSION}"
DST_DIR="${IMG_DIR}/${VERSION}"
# Create directory structure that will be mirrored on the target server.
mkdir -p "${SRC_DIR}-upload/${TMP_DIR}"
mv ${SRC_DIR}/* "${SRC_DIR}-upload/${TMP_DIR}"
# Use SFTP to upload images to the server.
sftp -P ${SSH_PORT} "${SSH_USER}@${SSH_HOST}" <<EOF
put -r ${SRC_DIR}-upload/*
rename "${TMP_DIR}" "${DST_DIR}"
sftp -P ${SSH_PORT} "${SSH_USER}@${SSH_HOST}" -b - <<EOF
put -R ${SRC_DIR}-upload/*
rename "${IMG_DIR}/.${VERSION}" "${IMG_DIR}/${VERSION}"
bye
EOF

0 comments on commit 9832955

Please sign in to comment.