Add docker build to CI script #4
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: "Run Tests" | |
on: | |
pull_request: | |
push: | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: cachix/install-nix-action@v20 | |
- uses: cachix/cachix-action@v12 | |
with: | |
name: edemocracy | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
- run: nix develop --impure -c ./test-setup.sh /tmp | |
- run: nix develop --impure -c pytest | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set lower case owner name | |
run: | | |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} | |
env: | |
OWNER: '${{ github.repository_owner }}' | |
- name: set tag to latest | |
run: | | |
sed -i 's/ contents/ tag = "latest";\n contents/' nix/docker.nix nix/docker_static.nix | |
- name: Build docker image | |
run: nix develop --impure -c build_docker | |
- name: Load app image | |
run: docker load -i docker-image-ekklesia-portal.tar | |
if: github.ref == 'refs/heads/piraten-bund' | |
- name: Load static image | |
run: docker load -i docker-image-ekklesia-portal-static.tar | |
if: github.ref == 'refs/heads/piraten-bund' | |
- name: Login to docker registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
if: github.ref == 'refs/heads/piraten-bund' | |
- name: Push docker image | |
run: docker push ghcr.io/${{ env.OWNER_LC }}/ekklesia-portal:latest | |
if: github.ref == 'refs/heads/piraten-bund' | |
- name: Push docker static image | |
run: docker push ghcr.io/${{ env.OWNER_LC }}/ekklesia-portal-static:latest | |
if: github.ref == 'refs/heads/piraten-bund' | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: Ekklesia Docker Images | |
path: docker-image-*.tar | |
# vim: set filetype=yaml sw=2 ts=2 sts=2 expandtab: |