release_services.yaml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ---
  2. name: build
  3. on:
  4. push:
  5. branches:
  6. - main
  7. pull_request:
  8. branches:
  9. - "*"
  10. permissions:
  11. contents: read
  12. packages: write
  13. jobs:
  14. build-image:
  15. strategy:
  16. matrix:
  17. apps:
  18. - name: job_sidecar_container
  19. - tag: job-sidecar
  20. runs-on: ubuntu-latest
  21. steps:
  22. - name: Checkout the repo
  23. uses: actions/checkout@v4
  24. - name: Get changed files in the docs folder
  25. id: changed-files-specific
  26. uses: tj-actions/changed-files@v40.2.0
  27. with:
  28. files: services/${{ matrix.apps.name }}/**
  29. - name: Set up QEMU
  30. if: steps.changed-files-specific.outputs.any_changed == 'true'
  31. uses: docker/setup-qemu-action@v3
  32. - name: Set up Docker Buildx
  33. if: steps.changed-files-specific.outputs.any_changed == 'true'
  34. uses: docker/setup-buildx-action@v3
  35. - name: Login to GitHub Package Registry
  36. if: steps.changed-files-specific.outputs.any_changed == 'true'
  37. uses: docker/login-action@v3
  38. with:
  39. registry: ghcr.io
  40. username: ${{github.actor}}
  41. password: ${{ secrets.GITHUB_TOKEN }}
  42. - name: Set Github tag
  43. if: steps.changed-files-specific.outputs.any_changed == 'true'
  44. id: vars
  45. run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
  46. - name: Build and push
  47. if: steps.changed-files-specific.outputs.any_changed == 'true'
  48. uses: docker/build-push-action@v5
  49. env:
  50. DOCKER_BUILDKIT: 1
  51. with:
  52. context: services/${{ matrix.apps.name }}
  53. platforms: linux/amd64,linux/arm64
  54. push: github.ref == 'refs/heads/main'
  55. tags: |
  56. ghcr.io/porter-dev/${{ matrix.apps.tag }}:${{ steps.vars.outputs.sha_short }}
  57. ghcr.io/porter-dev/${{ matrix.apps.tag }}:latest