git.iko.soy/typeable/octopod
on master help sign in
Rejiggered CI (#132)

* Rejiggered CI * don't use prod dockerhub * Added explicit bash shell * pass cachix singing key * checkout first * removed no-auto-link-without-protocol * pass docker hub creds as inputs * wip * wip

commit80739a2aea5d8269cda20e17aa17cb7a1ed4de45 authoriko <ilyakooo0@gmail.com> dateFri 8 Oct 2021, 19:18 (5 years ago) parent287d15b
6 files changed+130−159
.github/actions/common_setup/action.yaml+46 .github/actions/push_docker_images/action.yaml+26 .github/workflows/build.yaml+14−98 .github/workflows/check_documentation.yaml+1−1 .github/workflows/release.yaml+43 build.sh−60
.github/actions/common_setup/action.yamlnew file+46
@@ -0,0 +1,46 @@
1+name: "Common setup"
2+description: "Common setup steps"
3+inputs:
4+ cachixSigningKey:
5+ description: "Cachix signing key"
6+ required: true
7+runs:
8+ using: "composite"
9+ steps:
10+ - name: Install skopeo
11+ shell: bash
12+ run: |
13+ sudo apt-get -y update
14+ sudo apt-get -y install skopeo
15+
16+ - name: Increase swap
17+ shell: bash
18+ run: |
19+ free -h
20+
21+ sudo swapoff /mnt/swapfile
22+ sudo fallocate -l 12G /mnt/swapfile
23+ sudo mkswap /mnt/swapfile
24+ sudo swapon /mnt/swapfile
25+
26+ free -h
27+
28+ - name: Install Nix
29+ uses: cachix/install-nix-action@v12
30+ with:
31+ extra_nix_config: |
32+ trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
33+ substituters = https://hydra.iohk.io https://cache.nixos.org/
34+
35+ - name: Login to Cachix
36+ uses: cachix/cachix-action@v8
37+ with:
38+ name: octopod
39+ signingKey: ${{ inputs.cachixSigningKey }}
40+
41+ - name: Allow kvm in Nix
42+ shell: bash
43+ run: |
44+ # enable required features (see https://github.com/cachix/install-nix-action/issues/19)
45+ mkdir -p ~/.config/nix
46+ echo "system-features = kvm" >> ~/.config/nix/nix.conf
.github/actions/push_docker_images/action.yamlnew file+26
@@ -0,0 +1,26 @@
1+name: "Push Docker Images"
2+description: "Push Docker Images"
3+inputs:
4+ tag:
5+ description: "The docker image tag to push."
6+ required: true
7+ docker_username:
8+ description: "The Docker Hub username"
9+ required: true
10+ docker_password:
11+ description: "The Docker Hub password"
12+ required: true
13+runs:
14+ using: "composite"
15+ steps:
16+ - name: Login to DockerHub
17+ uses: docker/login-action@v1.10.0
18+ with:
19+ username: ${{ inputs.docker_username }}
20+ password: ${{ inputs.docker_password }}
21+
22+ - name: Push Docker Images to DockerHub
23+ shell: bash
24+ run: |
25+ skopeo copy docker-archive:$(nix-build ./nix -j auto -A octopod-server-container) docker://ilyakooo0/octopod:${{ inputs.tag }}
26+ skopeo copy docker-archive:$(nix-build ./nix -j auto -A octo-cli-container) docker://ilyakooo0/octo:${{ inputs.tag }}
.github/workflows/build.yaml+14−98
@@ -48,15 +48,10 @@ jobs:
4848 timeout-minutes: 600
4949 steps:
5050 - uses: actions/checkout@v2
51− - uses: cachix/install-nix-action@v12
52− with:
53− extra_nix_config: |
54− trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
55− substituters = https://hydra.iohk.io https://cache.nixos.org/
56− - uses: cachix/cachix-action@v8
51+ - name: Common setup
52+ uses: ./.github/actions/common_setup
5753 with:
58− name: octopod
59− signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
54+ cachixSigningKey: ${{ secrets.CACHIX_SIGNING_KEY }}
6055 - name: Build
6156 run: nix-build -A projectCross.musl64.hsPkgs.octo-cli.components.exes.octo --arg prod true -j auto
6257 - uses: actions/upload-artifact@v2
@@ -68,77 +63,27 @@ jobs:
6863 runs-on: ubuntu-latest
6964 timeout-minutes: 600
7065 steps:
71− - name: Increase swap
72− run: |
73− free -h
74−
75− sudo swapoff /mnt/swapfile
76− sudo fallocate -l 12G /mnt/swapfile
77− sudo mkswap /mnt/swapfile
78− sudo swapon /mnt/swapfile
79−
80− free -h - uses: actions/checkout@v2
81−
8266 - uses: actions/checkout@v2
8367
84− - name: Install Nix
85− uses: cachix/install-nix-action@v12
68+ - name: Common setup
69+ uses: ./.github/actions/common_setup
8670 with:
87− extra_nix_config: |
88− trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
89− substituters = https://hydra.iohk.io https://cache.nixos.org/
90−
91− - name: Login to Cachix
92− uses: cachix/cachix-action@v8
93− with:
94− name: octopod
95− signingKey: ${{ secrets.CACHIX_SIGNING_KEY }}
71+ cachixSigningKey: ${{ secrets.CACHIX_SIGNING_KEY }}
9672
9773 - name: Build Docker Images
98− run: |
99− # enable required features (see https://github.com/cachix/install-nix-action/issues/19)
100− mkdir -p ~/.config/nix
101− echo "system-features = kvm" >> ~/.config/nix/nix.conf
102−
103− # build docker images
104− ./build.sh build
105−
106− - name: Login to DockerHub
107− id: login-docker-hub
108− if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/develop'
109− uses: docker/login-action@v1
110− with:
111− username: ${{ secrets.DOCKERHUB_USERNAME }}
112− password: ${{ secrets.DOCKERHUB_TOKEN }}
113−
114− - name: Push Docker Images to DockerHub
115− if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging'
116− run: |
117− # push docker images to DockerHub
118− image_name=`cat octo-docker | docker load | awk '{print $3}'`
119− docker tag $image_name typeable/octo:latest
120− docker push typeable/octo:latest
121−
122− image_name=`cat octopod-server-docker | docker load | awk '{print $3}'`
123− docker tag $image_name typeable/octopod:latest
124− docker push typeable/octopod:latest
74+ run: nix-build ./nix -j auto
12575
12676 - name: Push Nightly Docker Images to DockerHub
127− if: github.ref == 'refs/heads/develop'
128− run: |
129− # push docker images to DockerHub
130− image_name=`cat octo-docker | docker load | awk '{print $3}'`
131− docker tag $image_name typeable/octo:nightly
132− docker push typeable/octo:nightly
133−
134− image_name=`cat octopod-server-docker | docker load | awk '{print $3}'`
135− docker tag $image_name typeable/octopod:nightly
136− docker push typeable/octopod:nightly
77+ uses: ./.github/actions/push_docker_images
78+ with:
79+ tag: nightly
80+ docker_username: ${{ secrets.DOCKERHUB_USERNAME }}
81+ docker_password: ${{ secrets.DOCKERHUB_TOKEN }}
13782
13883 - name: Rename Docker image archives
13984 run: |
140− mv octo-docker octo-cli-image.tar.gz
141− mv octopod-server-docker octopod-server-image.tar.gz
85+ cp $(nix-build ./nix -j auto -A octopod-server-container) octo-cli-image.tar.gz
86+ cp $(nix-build ./nix -j auto -A octo-cli-container) octopod-server-image.tar.gz
14287
14388 - name: Upload octo CLI Image
14489 uses: actions/upload-artifact@v2
@@ -151,32 +96,3 @@ jobs:
15196 with:
15297 name: octopod-server-image
15398 path: octopod-server-image.tar.gz
154−
155− - name: Clean up
156− if: always()
157− continue-on-error: true
158− run: |
159− docker logout ${{ steps.login-docker-hub.outputs.registry }}
160−
161− release:
162− name: "Release"
163− if: github.ref == 'refs/heads/master'
164− runs-on: "ubuntu-latest"
165− needs: [octo-macOS, octo-linux, docker-images]
166− steps:
167− - uses: actions/download-artifact@v2
168− - name: Zip
169− run: |
170− chmod +x octo-cli-macos/octo
171− zip octo-cli-macos octo-cli-macos/octo
172− chmod +x octo-cli-linux/octo
173− zip octo-cli-linux octo-cli-linux/octo
174− - uses: "marvinpinto/action-automatic-releases@latest"
175− with:
176− repo_token: "${{ secrets.GITHUB_TOKEN }}"
177− automatic_release_tag: "latest"
178− prerelease: true
179− title: "Pre-Release"
180− files: |
181− *.zip
182− *.tar.gz
.github/workflows/check_documentation.yaml+1−1
@@ -21,4 +21,4 @@ jobs:
2121
2222 - name: Run linter
2323 run: |
24− yarn run remark -f -u validate-links -u remark-lint-mdash-style -u remark-lint-final-newline -u remark-lint-list-item-bullet-indent -u remark-lint-no-auto-link-without-protocol -u remark-lint-no-blockquote-without-marker -u remark-lint-ordered-list-marker-style -u remark-lint-no-literal-urls -u remark-lint-hard-break-spaces -u remark-lint-no-duplicate-definitions -u remark-lint-no-heading-content-indent -u remark-lint-no-inline-padding -u remark-lint-no-shortcut-reference-image -u remark-lint-no-shortcut-reference-link -u remark-lint-no-undefined-references -u remark-lint-no-unused-definitions -u remark-lint-no-dead-urls docs README.md charts
24+ yarn run remark -f -u validate-links -u remark-lint-mdash-style -u remark-lint-final-newline -u remark-lint-list-item-bullet-indent -u remark-lint-no-blockquote-without-marker -u remark-lint-ordered-list-marker-style -u remark-lint-no-literal-urls -u remark-lint-hard-break-spaces -u remark-lint-no-duplicate-definitions -u remark-lint-no-heading-content-indent -u remark-lint-no-inline-padding -u remark-lint-no-shortcut-reference-image -u remark-lint-no-shortcut-reference-link -u remark-lint-no-undefined-references -u remark-lint-no-unused-definitions -u remark-lint-no-dead-urls docs README.md charts
.github/workflows/release.yamlnew file+43
@@ -0,0 +1,43 @@
1+name: Release
2+on:
3+ workflow_dispatch:
4+ inputs:
5+ version:
6+ description: The number of the version to release
7+ required: true
8+
9+jobs:
10+ release:
11+ name: "Release"
12+ runs-on: "ubuntu-latest"
13+ steps:
14+ - name: Common setup
15+ uses: ./.github/actions/common_setup
16+ with:
17+ cachixSigningKey: ${{ secrets.CACHIX_SIGNING_KEY }}
18+ - name: Push Nightly Docker Images to DockerHub
19+ uses: ./.github/actions/push_docker_images
20+ with:
21+ tag: ${{ inputs.version }}
22+ docker_username: ${{ secrets.DOCKERHUB_USERNAME }}
23+ docker_password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
25+ - uses: actions/download-artifact@v2
26+ - name: Zip and move
27+ run: |
28+ chmod +x octo-cli-macos/octo
29+ zip octo-cli-macos octo-cli-macos/octo
30+ chmod +x octo-cli-linux/octo
31+ zip octo-cli-linux octo-cli-linux/octo
32+
33+ mv octo-cli-image/* .
34+ mv octopod-server-image/* .
35+ - uses: "marvinpinto/action-automatic-releases@latest"
36+ with:
37+ repo_token: "${{ secrets.GITHUB_TOKEN }}"
38+ automatic_release_tag: "latest"
39+ prerelease: false
40+ title: "${{ inputs.version }}"
41+ files: |
42+ *.zip
43+ *.tar.gz
build.shdeleted−60
@@ -1,60 +0,0 @@
1−#!/usr/bin/env bash
2−
3−set -e
4−
5−build_octo_cli_docker_image() {
6− nix-build ./nix -A octo-cli-container -o "$1"
7−}
8−
9−build_octopod_server_docker_image() {
10− nix-build ./nix -A octopod-server-container --arg migrations "$1" -o "$2"
11−}
12−
13−push_docker_images() {
14− outfile=latest-octopod-server-docker
15− for image_name in $octo_cli_docker $octopod_server_docker; do
16− image_type=$(echo "$image_name" | cut -d- -f1)
17− image=$(ls -ls "$image_name" | awk '{print $12}')
18− echo "size: $(du -sh $image)"
19− docker load --input "$image" | tee "$outfile"
20− nixcontainer=$(awk '{print $3}' $outfile)
21− docker tag "$nixcontainer" "typeable/${image_type}:$1"
22− docker push "typeable/${image_type}:$1"
23− echo "Published: ${image_type}:$1"
24− done
25− rm $outfile
26−}
27−
28−build_docker_images() {
29− build_octo_cli_docker_image "$octo_cli_docker"
30− build_octopod_server_docker_image "$migrations" "$octopod_server_docker"
31−}
32−
33−export tag=$(git rev-parse HEAD)
34−export migrations="./migrations"
35−export octo_cli_docker="octo-docker"
36−export octopod_server_docker="octopod-server-docker"
37−
38−case "$1" in
39−build-and-push)
40− echo "$1 mode"
41−
42− if test -z "$2"; then
43− echo "Please provide a tag to upload to"
44− exit 1
45− fi
46−
47− build_docker_images
48− push_docker_images $2
49− ;;
50−build)
51− echo "$1 mode"
52− build_docker_images
53− ;;
54−*)
55− echo "usage:"
56− echo " $0 build Builds the docker images."
57− echo " $0 build-and-push <tag> Builds the docker images and uploads it to Docker Hub under the tag <tag>."
58− exit 1
59− ;;
60−esac