docker.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. name: Docker
  2. on:
  3. push:
  4. branches:
  5. - main
  6. pull_request:
  7. paths:
  8. - 'Dockerfile'
  9. - 'docker/**'
  10. - '.github/workflows/docker.yml'
  11. jobs:
  12. buildx:
  13. runs-on: ubuntu-latest
  14. steps:
  15. - name: Checkout code
  16. uses: actions/checkout@v2
  17. - name: Set up QEMU
  18. id: qemu
  19. uses: docker/setup-qemu-action@v1
  20. - name: Set up Docker Buildx
  21. id: buildx
  22. uses: docker/setup-buildx-action@v1
  23. with:
  24. config-inline: |
  25. [worker.oci]
  26. max-parallelism = 2
  27. - name: Inspect builder
  28. run: |
  29. echo "Name: ${{ steps.buildx.outputs.name }}"
  30. echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
  31. echo "Status: ${{ steps.buildx.outputs.status }}"
  32. echo "Flags: ${{ steps.buildx.outputs.flags }}"
  33. echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
  34. - name: Build images on pull requests
  35. if: ${{ github.event_name == 'pull_request' }}
  36. uses: docker/build-push-action@v2
  37. with:
  38. context: .
  39. platforms: linux/amd64,linux/arm64,linux/arm/v7
  40. - name: Login to Docker Hub
  41. if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
  42. uses: docker/login-action@v1
  43. with:
  44. username: ${{ secrets.DOCKERHUB_USERNAME }}
  45. password: ${{ secrets.DOCKERHUB_TOKEN }}
  46. - name: Login to GitHub Container registry
  47. if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
  48. uses: docker/login-action@v1
  49. with:
  50. registry: ghcr.io
  51. username: ${{ github.repository_owner }}
  52. password: ${{ secrets.GITHUB_TOKEN }}
  53. - name: Build and push images on commits to main
  54. if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
  55. uses: docker/build-push-action@v2
  56. with:
  57. context: .
  58. platforms: linux/amd64,linux/arm64,linux/arm/v7
  59. push: true
  60. tags: |
  61. gogs/gogs:latest
  62. ghcr.io/gogs/gogs:latest