Skip to content

Commit

Permalink
Merge pull request #285 from umccr/bugfix/use-gh-actions-user
Browse files Browse the repository at this point in the history
Use github actions user
  • Loading branch information
alexiswl authored Jun 25, 2024
2 parents 4a91919 + 5f38649 commit 41ed506
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
60 changes: 38 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ubuntu:24.04

# Set args
ARG CONDA_USER_NAME="ubuntu"
ARG CONDA_GROUP_NAME="ubuntu"
ARG CONDA_USER_ID=1000
ARG CONDA_GROUP_ID=1000
ARG GITHUB_ACTIONS_USERNAME="runner"
ARG GITHUB_ACTIONS_USER_ID=1001
ARG GITHUB_ACTIONS_GROUP_NAME="docker"
ARG GITHUB_ACTIONS_GROUP_ID=121
ARG CONDA_ENV_NAME="cwl-ica"
ARG YQ_VERSION="v4.35.2"
ARG ICAV2_CLI_VERSION="2.26.0"
Expand Down Expand Up @@ -109,6 +109,16 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
"https://stratus-documentation-us-east-1-public.s3.amazonaws.com/cli/${ICAV2_CLI_VERSION}/ica-linux-${TARGETPLATFORM#linux/}.zip" | \
busybox unzip -p - "linux-${TARGETPLATFORM#linux/}/icav2" > "/usr/local/bin/icav2" && \
chmod +x "/usr/local/bin/icav2" \
) && \
( \
echo "Adding user groups" 1>&2 && \
addgroup \
--gid "${GITHUB_ACTIONS_GROUP_ID}" \
"${GITHUB_ACTIONS_GROUP_NAME}" && \
adduser \
--disabled-password \
--gid "${GITHUB_ACTIONS_GROUP_ID}" \
--uid "${GITHUB_ACTIONS_USER_ID}" "${GITHUB_ACTIONS_USER_NAME}" \
)


Expand All @@ -118,30 +128,34 @@ COPY . "/cwl-ica-src-temp/"
RUN ( \
rsync \
--archive --remove-source-files \
--chown "${CONDA_USER_ID}:${CONDA_GROUP_ID}" "/cwl-ica-src-temp/" "/home/${CONDA_USER_NAME}/cwl-ica-src/" \
--chown "${GITHUB_ACTIONS_USER_ID}:${GITHUB_ACTIONS_GROUP_ID}" "/cwl-ica-src-temp/" "/home/${GITHUB_ACTIONS_USER_NAME}/cwl-ica-src/" \
)



# Switch to conda user
USER "${CONDA_USER_NAME}"
USER "${GITHUB_ACTIONS_USER_NAME}"
ENV PATH="${CONDA_DIR}/bin:${PATH}"

# Add conda command
RUN echo "Adding in package and env paths to conda arc" 1>&2 && \
conda config --append pkgs_dirs "\$HOME/.conda/pkgs" && \
conda config --append envs_dirs "\$HOME/.conda/envs" && \
echo "Installing into a conda env" 1>&2 && \
( \
cd "/home/${CONDA_USER_NAME}" && \
bash "cwl-ica-src/install.sh" -y -s && \
rm -rf "cwl-ica-src/" \
RUN ( \
echo "Adding in package and env paths to conda arc" 1>&2 && \
conda config --append pkgs_dirs "\$HOME/.conda/pkgs" && \
conda config --append envs_dirs "\$HOME/.conda/envs" && \
echo "Installing into a conda env" 1>&2 && \
( \
cd "/home/${GITHUB_ACTIONS_USER_NAME}" && \
bash "cwl-ica-src/install.sh" -y -s && \
rm -rf "cwl-ica-src/" \
) \
)

# Set environment variables for user
ENV CONDA_PREFIX="/home/${CONDA_USER_NAME}/.conda/envs/${CONDA_ENV_NAME}"
ENV CONDA_PREFIX="/home/${GITHUB_ACTIONS_USER_NAME}/.conda/envs/${CONDA_ENV_NAME}"
ENV CONDA_DEFAULT_ENV="${CONDA_ENV_NAME}"

RUN ( \
cd "/home/${CONDA_USER_NAME}" && \
cd "/home/${GITHUB_ACTIONS_USER_NAME}" && \
echo "Creating ${ICAV2_PLUGINS_CLI_CONDA_ENV_NAME} environment for icav2 cli plugins" 1>&2 && \
conda create --yes \
--name "${ICAV2_PLUGINS_CLI_CONDA_ENV_NAME}" \
Expand All @@ -151,27 +165,29 @@ RUN ( \
--output-document "icav2-plugins-cli--${ICAV2_PLUGINS_CLI_VERSION}.zip" \
"https://github.com/umccr/icav2-cli-plugins/releases/download/${ICAV2_PLUGINS_CLI_VERSION}/icav2-plugins-cli--${ICAV2_PLUGINS_CLI_VERSION}.zip" && \
unzip -qq "icav2-plugins-cli--${ICAV2_PLUGINS_CLI_VERSION}.zip" && \
PATH="/home/${CONDA_USER_NAME}/.conda/envs/${ICAV2_PLUGINS_CLI_CONDA_ENV_NAME}/bin:${PATH}" \
PATH="/home/${GITHUB_ACTIONS_USER_NAME}/.conda/envs/${ICAV2_PLUGINS_CLI_CONDA_ENV_NAME}/bin:${PATH}" \
bash "icav2-plugins-cli--${ICAV2_PLUGINS_CLI_VERSION}/install.sh" "--no-autocompletion" && \
rm -rf "icav2-plugins-cli--${ICAV2_PLUGINS_CLI_VERSION}" "icav2-plugins-cli--${ICAV2_PLUGINS_CLI_VERSION}.zip" \
)

ENV PATH="/home/${CONDA_USER_NAME}/.conda/envs/${CONDA_ENV_NAME}/bin:${PATH}"
ENV ICAV2_CLI_PLUGINS_HOME="/home/${CONDA_USER_NAME}/.icav2-cli-plugins/"
# Add conda env to path
ENV PATH="/home/${GITHUB_ACTIONS_USER_NAME}/.conda/envs/${CONDA_ENV_NAME}/bin:${PATH}"
# Set ICAv2 CLI plugins home
ENV ICAV2_CLI_PLUGINS_HOME="/home/${GITHUB_ACTIONS_USER_NAME}/.icav2-cli-plugins/"

# Add cwl-utils (with cwl-inputs-schema-gen) to cwl-ica environment
RUN ( \
cd "/home/${CONDA_USER_NAME}" && \
cd "/home/${GITHUB_ACTIONS_USER_NAME}" && \
echo "Cloning cwl-utils" 1>&2 && \
git clone --branch "${CWL_UTILS_REPO_BRANCH}" "${CWL_UTILS_REPO_PATH}" "cwl-utils" && \
echo "Installing cwl-utils" 1>&2 && \
( \
cd 'cwl-utils' && \
"/home/${CONDA_USER_NAME}/.conda/envs/${CONDA_ENV_NAME}/bin/pip" install . \
"/home/${GITHUB_ACTIONS_USER_NAME}/.conda/envs/${CONDA_ENV_NAME}/bin/pip" install . \
) && \
echo "Cleaning up" 1>&2 && \
rm -rf cwl-utils \
)


# Set entrypoint
CMD "cwl-ica"
5 changes: 3 additions & 2 deletions src/cwl_ica/subcommands/creators/create_workflow_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def git_checks(self):
capture_output=True
)
if get_remote_branch_returncode != 0:
logger.error("Could not get the upstream branch for this ")
logger.error("Could not get the upstream branch for this")
raise CheckArgumentError
remote_branch = get_remote_branch_stdout.strip()

Expand All @@ -169,12 +169,13 @@ def git_checks(self):
],
capture_output=True
)

# Set back log level
logger.setLevel(og_log_level)

# Delete tag from origin
if tag_remote_returncode == 0:
logger.info(f"Tag {self.tag} exists on the remote, will need to delete first")
logger.info(f"Tag {self.tag} exists on the remote, will delete on remote first")

# Delete tag
delete_tag_returncode, delete_tag_stdout, delete_tag_stderr = run_subprocess_proc(
Expand Down

0 comments on commit 41ed506

Please sign in to comment.