fix: branch #12
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: build-tag-push | |
| on: | |
| schedule: | |
| # At 00:00 on Sunday. | |
| - cron: "0 0 * * 0" | |
| push: | |
| branches: | |
| - main | |
| env: | |
| IMAGE_REPO: thspacecode | |
| IMAGE_NAME: erpnext-docker | |
| jobs: | |
| build-tag-push: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| app_branch: ["version-16"] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Set up Docker Compose | |
| uses: docker/setup-compose-action@v2 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and export to Docker | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: "{{defaultContext}}:dockerfile-bundled" | |
| tags: ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ matrix.app_branch }}-latest | |
| push: false | |
| load: true | |
| build-args: | | |
| APP_BRANCH=${{ matrix.app_branch }} | |
| - name: Start container | |
| working-directory: ./setup-trial-docker-compose | |
| run: | | |
| docker compose -p action-test up -d | |
| - name: Wait until site is ready (max 5 min) | |
| run: | | |
| timeout=300 | |
| elapsed=0 | |
| until curl -sf -o /dev/null http://127.0.0.1:8000; do | |
| if [ "$elapsed" -ge "$timeout" ]; then | |
| echo "Timed out after ${timeout}s waiting for port 8000" | |
| docker ps -a | |
| docker logs action-test-fp-main-1 | |
| exit 1 | |
| fi | |
| sleep 5 | |
| elapsed=$((elapsed + 5)) | |
| echo "Waiting... ${elapsed}s elapsed" | |
| done | |
| docker ps -a | |
| docker logs action-test-fp-main-1 | |
| echo "Site is up after ${elapsed}s" | |
| - name: Check HTTP Response | |
| run: | | |
| response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8000) | |
| if [ "$response" == 200 ]; then | |
| echo "Received a 200 response!" | |
| else | |
| echo "Failed to receive a 200 response, got: $response" | |
| exit 1 | |
| fi | |
| - name: Getting app version from image | |
| run: | | |
| docker exec action-test-fp-main-1 bench version > version.txt | |
| - name: Formatting and set version variable | |
| run: python ./.github/workflows/scripts/tag_image.py | |
| - name: Tag and push | |
| run: | | |
| docker tag ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ matrix.app_branch }}-latest ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION_TAG }} | |
| docker push ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION_TAG }} | |
| docker push ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ matrix.app_branch }}-latest |