tested good #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build and Push Containers | |
on: | |
push: | |
branches: [ "main" ] | |
paths: | |
- 'debian12-ssh/**' | |
- 'rocky93-ssh/**' | |
- 'scripts/**' | |
- '.github/workflows/build.yml' | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
env: | |
REGISTRY_HOST: ghcr.io | |
REGISTRY_USER: ${{ github.actor }} | |
REGISTRY_REPO: testing-containers | |
jobs: | |
build-containers: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
container_type: [ 'debian12-ssh', 'rocky93-ssh' ] | |
fail-fast: false | |
steps: | |
# ................................................................. | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# ................................................................. | |
- name: Set up environment variables | |
run: | | |
echo "CONTAINER_TOKEN=${{ secrets.CONTAINER_TOKEN }}" >> $GITHUB_ENV | |
echo "CONTAINER_TYPE=${{ matrix.container_type }}" >> $GITHUB_ENV | |
# ................................................................. | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y podman ansible | |
# Install collection in the GitHub workspace | |
ansible-galaxy collection install -p ./ community.docker | |
# ................................................................. | |
- name: Configure container environment | |
run: | | |
mkdir -p ~/.config/containers ~/.local/share/containers | |
chmod 700 ~/.config/containers ~/.local/share/containers | |
cat > ~/.config/containers/containers.conf << 'EOL' | |
[containers] | |
default_capabilities = ["CHOWN", "DAC_OVERRIDE", "FOWNER", "FSETID", "KILL", "NET_BIND_SERVICE", "SETFCAP", "SETGID", "SETPCAP", "SETUID", "SYS_CHROOT"] | |
[engine] | |
runtime = "crun" | |
cgroup_manager = "cgroupfs" | |
events_logger = "journald" | |
EOL | |
# podman system info | |
# ................................................................. | |
- name: Build container | |
env: | |
REGISTRY_HOST: ghcr.io | |
REGISTRY_USER: ${{ github.repository_owner }} | |
REGISTRY_REPO: testing-containers | |
CONTAINER_TYPE: ${{ matrix.container_type }} | |
CONTAINER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SSH_KEY: ${{ secrets.SSH_KEY }} | |
ANSIBLE_COMMON_ARGS: "-e ansible_connection=community.docker.docker" | |
run: ./scripts/build_container.sh | |
# ................................................................. | |
- name: Upload logs on failure | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-logs-${{ matrix.container-type }} | |
path: | | |
.working/${{ matrix.container-type }}/ | |
~/.local/share/containers/ | |
if-no-files-found: warn | |
include-hidden-files: false |