fix(ci): fix sintax matching #7
This file contains hidden or 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: CI/CD for Nix Dotfiles | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build-docker-image: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_name: ${{ steps.build.outputs.image_name }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Build docker image | |
| id: build | |
| run: | | |
| IMAGE_NAME="nix-test-env:$(git rev-parse --short HEAD)" | |
| docker build -t ${IMAGE_NAME} -f ./nix_test_env/Dockerfile . | |
| echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
| - name: Save Docker image | |
| run: | | |
| docker save ${{ steps.build.outputs.image_name }} -o nix-image.tar | |
| - name: Upload Docker image artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nix-docker-image | |
| path: nix-image.tar | |
| tests: | |
| runs-on: ubuntu-latest | |
| needs: build-docker-image | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Download Docker image artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nix-docker-image | |
| - name: Load Docker image | |
| run: | | |
| docker load -i nix-image.tar | |
| - name: Run container | |
| run: | | |
| CONTAINER_NAME="nix-test-container" | |
| IMAGE_NAME="${{ needs.build-docker-image.outputs.image_name }}" | |
| docker run --name ${CONTAINER_NAME} -d ${IMAGE_NAME} tail -f /dev/null | |
| - name: Run Git config test in container | |
| run: | | |
| docker exec ${CONTAINER_NAME} home-manager switch | |
| docker exec ${CONTAINER_NAME} bash -c \ | |
| "source /root/.nix-profile/etc/profile.d/nix.sh && \ | |
| git config --global user.name | grep 'PedroBrantes'" | |
| - name: Run Editor env test in container | |
| run: | | |
| docker exec ${CONTAINER_NAME} home-manager switch | |
| docker exec ${CONTAINER_NAME} bash -c \ | |
| "source /root/.nix-profile/etc/profile.d/nix.sh && \ | |
| printenv EDITOR | grep 'nvim'" | |
| - name: Clean up container | |
| run: | | |
| docker rm -f ${CONTAINER_NAME} # Clean up after test |