docker-fortuna.yml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. name: Build and Push Fortuna Image
  2. on:
  3. push:
  4. tags:
  5. - fortuna-v*
  6. pull_request:
  7. paths:
  8. - "apps/fortuna/**"
  9. workflow_dispatch:
  10. inputs:
  11. dispatch_description:
  12. description: "Dispatch description"
  13. required: true
  14. type: string
  15. permissions:
  16. contents: read
  17. id-token: write
  18. packages: write
  19. env:
  20. REGISTRY: ghcr.io
  21. IMAGE_NAME: pyth-network/fortuna
  22. jobs:
  23. fortuna-image:
  24. runs-on: ubuntu-latest
  25. steps:
  26. - uses: actions/checkout@v2
  27. - name: Set image tag to version of the git tag
  28. if: ${{ startsWith(github.ref, 'refs/tags/fortuna-v') }}
  29. run: |
  30. PREFIX="refs/tags/fortuna-"
  31. VERSION="${GITHUB_REF:${#PREFIX}}"
  32. echo "IMAGE_TAG=${VERSION}" >> "${GITHUB_ENV}"
  33. - name: Set image tag to the git commit hash
  34. if: ${{ !startsWith(github.ref, 'refs/tags/fortuna-v') }}
  35. run: |
  36. echo "IMAGE_TAG=${{ github.sha }}" >> "${GITHUB_ENV}"
  37. - name: Log in to the Container registry
  38. uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
  39. with:
  40. registry: ${{ env.REGISTRY }}
  41. username: ${{ github.actor }}
  42. password: ${{ secrets.GITHUB_TOKEN }}
  43. - name: Extract metadata (tags, labels) for Docker
  44. id: metadata_fortuna
  45. uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
  46. with:
  47. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  48. - name: Build and push server docker image
  49. uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
  50. with:
  51. context: .
  52. file: "./apps/fortuna/Dockerfile"
  53. push: ${{ github.event_name != 'pull_request' }}
  54. tags: ${{ steps.metadata_fortuna.outputs.tags }}
  55. labels: ${{ steps.metadata_fortuna.outputs.labels }}