diff --git a/.github/workflows/dev-image.yml b/.github/workflows/dev-image.yml new file mode 100644 index 00000000..1f9ea0ae --- /dev/null +++ b/.github/workflows/dev-image.yml @@ -0,0 +1,75 @@ +name: Create Dev-Image + +on: + pull_request: + branches: + - main + - dev + types: + - opened + - synchronize + - reopened + +jobs: + docker: + runs-on: ubuntu-latest + + env: + TAG_URL: https://hub.docker.com/r/${{ vars.DOCKER_HUB_REPO }}/tags + TAG: ${{ vars.DOCKER_HUB_REPO }}:dev-pr${{ github.event.pull_request.number }} + TAG_PG: ${{ vars.DOCKER_HUB_REPO }}:postgresql-dev-pr${{ github.event.pull_request.number }} + + steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image SQLITE + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64 + push: true + tags: ${{ env.TAG }} + cache-from: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache + cache-to: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache,mode=max + build-args: DATABASE=sqlite + + - name: Build and push Docker image PG + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64 + push: true + tags: ${{ env.TAG_PG }} + cache-from: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache-pg + cache-to: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache-pg,mode=max + build-args: DATABASE=pg + + - uses: actions/github-script@v8 + with: + script: | + const repoUrl = process.env.TAG_URL; + const tag = process.env.TAG; + const tagPg = process.env.TAG_PG; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `👋 Thanks for your PR! + Dev images for this PR are now available on [docker hub](${repoUrl}): + + **SQLITE Image:** + \`\`\` + ${tag} + \`\`\` + + **Postgresql Image:** + \`\`\` + ${tagPg} + \`\`\`` + }) +