|
| 1 | +# https://www.docker.com/blog/docker-v2-github-action-is-now-ga/ |
| 2 | +# https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/ |
| 3 | +# https://docs.github.com/en/actions/guides/publishing-docker-images |
| 4 | + |
| 5 | +name: 'Docker Integration Tests and Release' |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - "*" |
| 11 | + tags: |
| 12 | + - 'v*' |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + arch: |
| 20 | + - x86 |
| 21 | + - armhf |
| 22 | + - arm64 |
| 23 | + fail-fast: false |
| 24 | + steps: |
| 25 | + - name: Setup Docker Buildx |
| 26 | + uses: docker/setup-buildx-action@v1 |
| 27 | + |
| 28 | + - name: Set up QEMU |
| 29 | + uses: docker/setup-qemu-action@v1 |
| 30 | + |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v3 |
| 33 | + |
| 34 | + - name: Login to docker |
| 35 | + run: | |
| 36 | + echo "${{ secrets.DOCKER_PASSWORD_INTERNAL }}" | docker login -u "${{ secrets.DOCKER_LOGIN_INTERNAL }}" --password-stdin |
| 37 | +
|
| 38 | + - name: Build images |
| 39 | + id: build-container |
| 40 | + run: | |
| 41 | + ./build/build-docker.sh "${{ matrix.arch }}" |
| 42 | + docker tag "ownyourbits/nextcloudpi-${{ matrix.arch }}:latest" "thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }}" |
| 43 | + docker push "thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }}" |
| 44 | +
|
| 45 | + test: |
| 46 | + needs: |
| 47 | + - build |
| 48 | + runs-on: ubuntu-latest |
| 49 | + |
| 50 | + strategy: |
| 51 | + matrix: |
| 52 | + arch: |
| 53 | + - armhf |
| 54 | + - x86 |
| 55 | + - arm64 |
| 56 | + fail-fast: false |
| 57 | + steps: |
| 58 | + - name: Set up QEMU |
| 59 | + uses: docker/setup-qemu-action@v1 |
| 60 | + |
| 61 | + - name: Login to docker |
| 62 | + run: | |
| 63 | + echo "${{ secrets.DOCKER_PASSWORD_INTERNAL }}" | docker login -u "${{ secrets.DOCKER_LOGIN_INTERNAL }}" --password-stdin |
| 64 | + - name: Start ncp container |
| 65 | + run: | |
| 66 | + docker run -d --rm -p 8443:443 -p 4443:4443 --name nextcloudpi thecalcaholic/ncp-internal-${{ matrix.arch }}:${{ github.run_id }} |
| 67 | +
|
| 68 | + - name: Checkout code |
| 69 | + uses: actions/checkout@v3 |
| 70 | + |
| 71 | + - name: Setup Firefox |
| 72 | + uses: browser-actions/setup-firefox@latest |
| 73 | + - name: Setup GeckoDriver |
| 74 | + uses: browser-actions/setup-geckodriver@latest |
| 75 | + - name: Setup Selenium |
| 76 | + run: pip install selenium |
| 77 | + |
| 78 | + - name: Integration Tests |
| 79 | + working-directory: ./tests |
| 80 | + run: | |
| 81 | + python activation_tests.py --no-gui localhost 8443 4443 || { |
| 82 | + tail -n 20 geckodriver.log >&2 || true |
| 83 | + echo "=======================" |
| 84 | + echo "Activation test failed!" |
| 85 | + echo "Container logs:" |
| 86 | + echo "===========================================" |
| 87 | + docker logs nextcloudpi |
| 88 | + echo "Last lines of ncp.log:" |
| 89 | + echo "===========================================" |
| 90 | + docker exec nextcloudpi tail /var/log/ncp.log; |
| 91 | + exit 1 |
| 92 | + } |
| 93 | + echo "Activation test successful" |
| 94 | + python system_tests.py --no-ping --non-interactive || { |
| 95 | + echo "System test failed!" |
| 96 | + exit 1 |
| 97 | + } |
| 98 | + echo "System test successful" |
| 99 | + python nextcloud_tests.py --no-gui localhost 8443 4443 || { |
| 100 | + tail -n 20 geckodriver.log >&2 || true |
| 101 | + echo "=======================" |
| 102 | + echo "Nextcloud test failed!" |
| 103 | + echo "Container logs:" |
| 104 | + echo "===========================================" |
| 105 | + docker logs nextcloudpi |
| 106 | + echo "Last lines of ncp.log:" |
| 107 | + echo "===========================================" |
| 108 | + docker exec nextcloudpi tail /var/log/ncp.log; |
| 109 | + exit 1 |
| 110 | + } |
| 111 | + echo "Nextcloud test successful" |
| 112 | +
|
| 113 | + release: |
| 114 | + needs: |
| 115 | + - test |
| 116 | + if: ${{ github.event_name == 'push' && github.github.ref_type == 'tag' }} |
| 117 | + runs-on: ubuntu-latest |
| 118 | + steps: |
| 119 | + - name: Login to DockerHub |
| 120 | + uses: docker/login-action@v1 |
| 121 | + with: |
| 122 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 123 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 124 | + |
| 125 | + - name: Create manifest and push as tag to docker hub |
| 126 | + run: | |
| 127 | + . ./build/buildlib.sh |
| 128 | + |
| 129 | + for arch in x86 armhf arm64 |
| 130 | + do |
| 131 | + docker pull "thecalcaholic/ncp-internal-${arch}:${{ github.run_id }}" |
| 132 | + docker tag "thecalcaholic/ncp-internal-${arch}:${{ github.run_id }}" "ownyourbits/nextcloudpi-${arch}:${version?}" |
| 133 | + done |
| 134 | +
|
| 135 | + docker manifest create ownyourbits/nextcloudpi:${version?} \ |
| 136 | + ownyourbits/nextcloudpi-armhf:${version?} \ |
| 137 | + ownyourbits/nextcloudpi-x86:${version?} \ |
| 138 | + ownyourbits/nextcloudpi-arm64:${version?} |
| 139 | + docker manifest push ownyourbits/nextcloudpi:${version?} |
| 140 | +
|
| 141 | + - name: Create manifest and push as latest to docker hub |
| 142 | + run: | |
| 143 | + docker manifest create ownyourbits/nextcloudpi:latest \ |
| 144 | + ownyourbits/nextcloudpi-armhf:latest \ |
| 145 | + ownyourbits/nextcloudpi-x86:latest \ |
| 146 | + ownyourbits/nextcloudpi-arm64:latest |
| 147 | + docker manifest push ownyourbits/nextcloudpi:latest |
0 commit comments