Skip to content

Add publishing to DockerHub #70

Add publishing to DockerHub

Add publishing to DockerHub #70

Workflow file for this run

name: "CI Full Run"
on:
pull_request:
branches:
- main
- grok/*/*
push:
branches:
- main
jobs:
# Tests ci-storage tool itself.
ci-storage-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create dummy file
run: |
echo "dummy" > dummy.txt
echo -n "" > ~/ci-storage-host
- name: Test store
uses: ./
with:
action: "store"
- name: Remove dummy file
run: rm dummy.txt
- name: Test load
uses: ./
with:
action: "load"
- name: Check that dummy file was restored
run: |
set -e
ls -la ~/ci-storage/dimikot/ci-storage
[ "$(cat dummy.txt)" = "dummy" ] || { echo "dummy.txt was not restored"; exit 1; }
# Builds and boots a self-hosted runner inside GitHub's infra. Once it's
# settled, there is a running container with one self-hosted runner waiting
# for jobs with "ci-storage-test" tag to pick up (based on Dockerfile image).
self-hosted-runner-build-and-boot-docker-container:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Start test Docker containers
run: |
exec 2>&1; set -e -o xtrace
cd docker
# Build all containers.
docker compose build --parallel
# Boot "host" container in background.
docker compose up host -d
# Boot "self-hosted-runner" container. It connects to "host" container
# and load a test (non-existent) ci-storage slot from there, then
# register a GitHub self-hosted runner and remain waiting for jobs.
docker compose up self-hosted-runner
env:
GH_REPOSITORY: ${{ github.repository }}
GH_LABELS: ci-storage-test
GH_TOKEN: ${{ secrets.CI_PAT }}
# The test job with ci-storage-test tag which is initially queued, but then is
# picked up by the self-hosted-runner container booted in the previous job. In
# the end, the test job sends SIGINT to the container entrypoint.sh PID, so
# the container (based on Dockerfile image) shuts down gracefully.
self-hosted-runner-spawn-job-test:
runs-on: ["self-hosted", "ci-storage-test"]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run test job inside the self-hosted runner
run: echo "Hello, world!"
- name: Test store using GitHub Action
uses: ./
with:
action: "store"
- name: Kill self-hosted runner container
run: kill -SIGINT $(cat ~user/entrypoint.pid)
# Publishes images to Docker Hub.
self-hosted-runner-publish-images:
runs-on: ubuntu-latest
# needs:
# - self-hosted-runner-build-and-boot-docker-container
# - self-hosted-runner-spawn-job-test
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: dimikot
password: ${{ secrets.DOCKERHUB_PAT }}
- name: Build and push host
uses: docker/build-push-action@v5
with:
context: docker/host
tags: dimikot/ci-storage-host:latest
push: false
- name: Build and push self-hosted-runner
uses: docker/build-push-action@v5
with:
context: docker/self-hosted-runner
tags: dimikot/ci-storage-self-hosted-runner:latest
push: false