nightly #1095
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: nightly | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Remove unnecessary files | |
| run: | | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - uses: actions/checkout@v2 | |
| - name: Upgrade QEMU | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y qemu binfmt-support qemu-user-static | |
| - name: Fix QEMU binfmt | |
| run: | | |
| docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build the Docker image | |
| run: | | |
| echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io | |
| MYAPP_VERSION=$(git rev-parse --short HEAD) | |
| docker buildx create --name mybuilder --driver docker-container --bootstrap --use | |
| docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
| for i in {1..3}; do | |
| docker buildx build --platform linux/amd64,linux/arm64 --build-arg BUILD_NAME=myapp --build-arg MYAPP_VERSION=${MYAPP_VERSION} --build-arg UPGRADE_REQS="yes" --no-cache -t docker.io/mpgagebioinformatics/myapp:nightly -f services/server/Dockerfile --push . && break | |
| echo "Build failed (attempt $i). Retrying in 30s..." | |
| sleep 30 | |
| done | |
| - name: Set Success env | |
| run: echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-8)" >> $GITHUB_ENV | |
| - name: Slack Success Notification | |
| run: | | |
| generate_post_data() | |
| { | |
| cat << EOF | |
| { | |
| "text": "myapp $GITHUB_SHA_SHORT nightly build and push completed" | |
| } | |
| EOF | |
| } | |
| curl -H "Content-Type: application/json" -X POST -d "$(generate_post_data)" ${{ secrets.SLACK_WEBHOOK }} | |
| - name: Set Failure env | |
| if: failure() | |
| run: echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-8)" >> $GITHUB_ENV | |
| - name: Slack Failure Notification | |
| if: failure() | |
| run: | | |
| generate_post_data() | |
| { | |
| cat << EOF | |
| { | |
| "text": "myapp $GITHUB_SHA_SHORT nightly build and push FAILED" | |
| } | |
| EOF | |
| } | |
| curl -H "Content-Type: application/json" -X POST -d "$(generate_post_data)" ${{ secrets.SLACK_WEBHOOK }} | |