61 lines
1.9 KiB
YAML
61 lines
1.9 KiB
YAML
name: Create OCI image(s)
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
registry: git.amarth.cloud
|
|
owner: amarth
|
|
image: default
|
|
tag: latest
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and push images
|
|
runs-on: default
|
|
steps:
|
|
- name: Install dependencies
|
|
run: |
|
|
# configure container policy to accept insecure registry
|
|
nix-env -iA nixpkgs.nodejs nixpkgs.podman nixpkgs.kvmtool nixpkgs.curl nixpkgs.jq
|
|
|
|
# configure container policy to accept insecure registry
|
|
mkdir -p ~/.config/containers
|
|
echo '{ "default": [ {"type":"insecureAcceptAnything"} ] }' > ~/.config/containers/policy.json
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Log into registry
|
|
run: |
|
|
podman login \
|
|
--authfile ~/.config/containers/auth.json \
|
|
--username "${{ forge.actor }}" \
|
|
--password "${{ forge.token }}" \
|
|
${{ env.registry }}
|
|
|
|
# curl --fail -u${{ forge.actor }}:${{ forge.token }} -sS ${{ env.registry }}/v2/token | jq --raw-output '"Authorization: token \(.token)"' > /tmp/forgejo_token
|
|
curl --fail -u${{ forge.actor }}:${{ forge.token }} -sS ${{ env.registry }}/v2/token > /tmp/forgejo_token
|
|
|
|
- name: __DEBUG__
|
|
run: |
|
|
echo "~/.config/containers/auth.json"
|
|
[ -f ~/.config/containers/auth.json ] && cat ~/.config/containers/auth.json || echo "file doesn't exist"
|
|
|
|
echo "/tmp/forgejo_token"
|
|
[ -f /tmp/forgejo_token ] && cat /tmp/forgejo_token || echo "file doesn't exist"
|
|
|
|
- name: Create image
|
|
run: |
|
|
nix-build src/default.nix
|
|
podman load < result
|
|
|
|
- name: Push image
|
|
run: >-
|
|
podman push
|
|
--log-level=debug
|
|
--authfile ~/.config/containers/auth.json
|
|
localhost/default:latest
|
|
${{ env.registry }}/${{ env.owner }}/${{ env.image }}:${{ env.tag }}
|