1
0
Fork 0
forked from pim/blog

Add Forgejo action to build Docker image

This commit is contained in:
Pim Kunis 2024-04-30 23:10:28 +02:00
parent 649566c8ab
commit fe9488d31c
3 changed files with 101 additions and 31 deletions

View file

@ -4,18 +4,21 @@ jobs:
runs-on: docker
container:
image: git.kun.is/home/forgejo-nix-action:687d16c49ea7936068bac64ec68c480a9d681962
env:
GIT_COMMITTER_NAME: Forgejo Action
GIT_COMMITTER_EMAIL: noreply@git.kun.is
GIT_AUTHOR_NAME: Forgejo Action
GIT_AUTHOR_EMAIL: noreply@git.kun.is
steps:
- name: Clone container-images repository
run: git clone https://${{ secrets.RUNNER_TOKEN }}@${GITHUB_SERVER_URL#https://}/home/container-images.git container-images
- name: Update Nix input on container-images
run: nix flake lock --update-input blog-pim ./container-images
- name: Push changes to container-images repo
- name: Clone repository
run: git clone ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git src
- name: Setup Nix cache
run: |
git --git-dir container-images/.git --work-tree container-images add -A
git --git-dir container-images/.git --work-tree container-images commit --message "Bump blog-pim Nix flake input"
git --git-dir container-images/.git --work-tree container-images push
/bin/attic login local ${{ vars.ATTIC_URL }} ${{ secrets.ATTIC_TOKEN }}
/bin/attic use ${{ vars.ATTIC_CACHE }}
- name: Build image
run: nix build --out-link image ./src#packages.x86_64-linux.container-image
- name: Push image to Nix cache
run: /bin/attic push ${{ vars.ATTIC_CACHE }} image
- name: Log into container registry
run: /bin/skopeo login --tls-verify --username ${{ vars.RUNNER_USER }} --password ${{ secrets.RUNNER_TOKEN }} ${GITHUB_SERVER_URL}
- name: Push image to container registry
run: |
/bin/skopeo --insecure-policy copy docker-archive:image docker://${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY_OWNER}/blog-pim:latest
gitrev=$(git --git-dir src/.git --work-tree src rev-parse HEAD)
/bin/skopeo --insecure-policy copy docker-archive:image docker://${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY_OWNER}/blog-pim:$gitrev