Adding action to add nix capabilities to docker runner #2

Open
eoghanconlon73 wants to merge 20 commits from eoghanconlon73/actions:main into main
4 changed files with 61 additions and 1 deletions

View file

@ -104,3 +104,25 @@ jobs:
folder: "src" folder: "src"
#destination: "subfolder" #destination: "subfolder"
``` ```
## Docker Nix
This action is used to get nix into the docker user deploy system.
### v7
```yaml
jobs:
build:
runs-on: docker
steps:
uses: https://forgejo.skynet.ie/Skynet/actions/docker_nix@v7

Id say just set it to be v7, since that is what I will be tagging it with

Id say just set it to be ``v7``, since that is what I will be tagging it with

Perfect, was more leaving it as generic as I wanted to have one change at the end for the version

Perfect, was more leaving it as generic as I wanted to have one change at the end for the version
```
## Nix build Deploy user
This action can build your website if you develop it using different methods than writing HTML. Only pre-requisite is that
this action uses the Nix build command, so your repository requires a nix flake.
```yaml
jobs:
build:
runs-on: docker
steps:
uses: https://forgejo.skynet.ie/Skynet/actions/nix-build_deploy@v7
```

View file

@ -23,4 +23,4 @@ ssh ${USERNAME}@skynet.skynet.ie "mkdir -p ~/public_html && chmod 711 ~ || true
ssh ${USERNAME}@skynet.skynet.ie "mkdir -p ~/public_html/${DESTINATION}" ssh ${USERNAME}@skynet.skynet.ie "mkdir -p ~/public_html/${DESTINATION}"
# copy files across # copy files across
scp -r ${FOLDER}/* ${USERNAME}@skynet.skynet.ie:/home/${USERNAME}/public_html/${DESTINATION} scp -rL ${FOLDER}/* ${USERNAME}@skynet.skynet.ie:/home/${USERNAME}/public_html/${DESTINATION}

19
docker_nix/action.yml Normal file
View file

@ -0,0 +1,19 @@
name: 'Get image ready to run nix jobs'
description: 'Update apt repositories and installing sudo'
runs:
using: 'composite'
steps:
- name: 'Installing nix on Docker runner'

It is more that sudo is required for the installer to run.

It is more that ``sudo`` is required for the installer to run.
shell: bash
run: |
apt update
apt upgrade -y
apt install -y sudo
- uses: https://github.com/cachix/install-nix-action@v29
with:
nix_path: nixpkgs=channel:nixos-unstable

What if someone wants to specify what version of nix to use?

The inputs fot teh install-nix-action can be found here: https://github.com/cachix/install-nix-action?tab=readme-ov-file#inputs-specify-using-with

(I honestly dont think anyone would really use this, more food to think for the future (we can revisit if someone needs it))

What if someone wants to specify what version of nix to use? The inputs fot teh install-nix-action can be found here: https://github.com/cachix/install-nix-action?tab=readme-ov-file#inputs-specify-using-with (I honestly dont think anyone would really use this, more food to think for the future (we can revisit if someone needs it))

perfect, I'll have a look into this there in a few minutes

perfect, I'll have a look into this there in a few minutes

This didn't work as I expected, it still installs nix so may be alright to be fixed in a later version of the action, though can revert back to unstable if that's preferred

This didn't work as I expected, it still installs nix so may be alright to be fixed in a later version of the action, though can revert back to unstable if that's preferred
extra_nix_config: |
trusted-public-keys = skynet-cache:zMFLzcRZPhUpjXUy8SF8Cf7KGAZwo98SKrzeXvdWABo= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://nix-cache.skynet.ie/skynet-cache https://hydra.iohk.io https://cache.nixos.org/
- shell: bash
run: nix --version

View file

@ -0,0 +1,19 @@
name: "Deploying from a Nix Build"
description: "Deploys a website when built from a nix flake"
runs:
using: 'composite'
steps:
- uses: https://forgejo.skynet.ie/eoghanconlon73/actions/docker_nix@eoghan_test-final3
- uses: https://code.forgejo.org/actions/checkout@v4
- uses: https://forgejo.skynet.ie/Skynet/actions/get_lfs@v6
with:
repository: ${{ gitea.repository }}
ref_name: ${{ gitea.ref_name }}
- run: nix build
- run: mkdir temp
- run: cp -rL result/* ./temp
- uses: https://forgejo.skynet.ie/Skynet/actions/deploy_user@v6
with:
ssh_key: ${{ secrets.SSH_KEY }}
username: ${{ env.GITHUB_REPOSITORY_OWNER }}
folder: "result"