Closed aannara closed 3 months ago
Hey @aannara,
You can do that by modifying the hook. However, depending on your requirements, I would prefer using a step that always execute. Again, not sure exactly if that would help you, if you can solve it with the workflow, you can avoid maintaining the hook yourself :relaxed:
Hey @aannara,
You can do that by modifying the hook. However, depending on your requirements, I would prefer using a step that always execute. Again, not sure exactly if that would help you, if you can solve it with the workflow, you can avoid maintaining the hook yourself ☺️
Maybe I am missing the idea here. I want to push the actual container running the github actions to a registry. always is used with a step which is inside the container. Can I use always to fetch and push the container itself ?
Could you please elaborate? I really don't understand the use-case. In your workflow, you use:
container: example-container
Now, you would like to push the same container to the registry? But containers are immutable, so there would be no change, and therefore you would be pushing the same image? If you are re-building one, then use a step to push the new image upstream.
I'm sorry, but I really don't understand the problem...
Let's say below is my workflow file:
jobs:
job-name:
runs-on: self-hosted
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
container:
image: ubuntu:22.04
steps:
- name: Install system dependencies
run: |
apt update -y
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Run Python script
run: python3 my_script.py
This workflow will trigger Initialize containers
step which creates the container, then run each of my steps inside this container. Now I want this container, which contains "ubuntu + git checkout + set python + python script" to be pushed to a repository.
Is this not possible by using the cleanup_job hook? Or will the container still be vanilla ubuntu image?
This is not possible. Each image is immutable. Regardless of what you install inside the image, it still changes only it's runnable state. You can test it by running Ubuntu and downloading something. If you exit the container and start it again, you will lose the state previously installed. You want to build a new image with the Ubuntu base, and push the new image with dependencies installed.
I want to use the cleanup_job hook to upload the container as is to private registry after job is completed. Am I expected to add this logic directly into "packages/docker/src/hooks/cleanup-job.ts" and then build it? Or is there a more appropriate place to do this? I still want the normal cleanup activities to happen, I just want to add this step before any container cleanup happens