CI #3
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 | |
| on: | |
| push: | |
| schedule: | |
| - cron: "35 */6 * * *" | |
| jobs: | |
| configure: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - name: Checkout to repository | |
| uses: actions/checkout@v4 | |
| - name: Set matrix data | |
| id: set-matrix | |
| run: echo "matrix=$(jq -c . < ./distro_versions.json)" >> $GITHUB_OUTPUT | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: configure | |
| strategy: | |
| # allow pushing successfully built images anyway | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.configure.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Generate Dockerfile | |
| run: ./crypt-keeper.sh generate ${{ matrix.os }} ${{ matrix.version }} | |
| - name: Log in to Docker Hub | |
| run: docker login -u="${{ secrets.DOCKER_USER }}" -p="${{ secrets.DOCKER_PASS }}" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Build And Push Docker Image with Retry | |
| run: | | |
| MAX_ATTEMPTS=10 | |
| for attempt in $(seq 1 $MAX_ATTEMPTS); do | |
| echo "Attempt $attempt of $MAX_ATTEMPTS: Building Docker image..." | |
| ./crypt-keeper.sh build ${{ matrix.os }} ${{ matrix.version }} && break | |
| EXIT_CODE=$? | |
| echo "Attempt $attempt failed with exit code $EXIT_CODE." | |
| if [ "$attempt" -lt "$MAX_ATTEMPTS" ]; then | |
| echo "Retrying in 30 seconds..." | |
| sleep 30 | |
| else | |
| echo "All $MAX_ATTEMPTS attempts failed." | |
| exit $EXIT_CODE | |
| fi | |
| done | |
| - name: Test DEB Build using the image (x86_64) | |
| run: | | |
| echo "Testing x86_64 build for ${{ matrix.os }}-${{ matrix.version }}" | |
| docker run --rm --platform linux/amd64 \ | |
| -v "$(pwd)"/tests:/sources \ | |
| -v "$(pwd)"/output:/output \ | |
| "$(./crypt-keeper.sh docker-image-name ${{ matrix.os }} ${{ matrix.version }})" build | |
| - name: Push to Docker Hub | |
| run: ./crypt-keeper.sh push ${{ matrix.os }} ${{ matrix.version }} |