Spaces:
Paused
Paused
| name: Docker Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - Dockerfile | |
| - docker-entrypoint.sh | |
| - .github/workflows/docker-build.yml | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build Image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| contents: read | |
| steps: | |
| - name: Checkout current repo | |
| uses: actions/checkout@v2 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set ENV Variables | |
| run: | | |
| IMG="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" | |
| bot_git_version=$(git rev-parse --short HEAD) | |
| echo "BUILD_VER=bot_git_version" >> $GITHUB_ENV | |
| echo "IMAGE=${IMG}" >> $GITHUB_ENV | |
| echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV | |
| echo "GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV | |
| echo "GIT_REF=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" >> $GITHUB_ENV | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v1 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Build and push | |
| id: docker_build | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| tags: | | |
| ghcr.io/${{ env.IMAGE }}:latest | |
| ghcr.io/${{ env.IMAGE }}:${{ env.BUILD_VER }} | |
| ${{ env.IMAGE }}:latest | |
| ${{ env.IMAGE }}:${{ env.BUILD_VER }} | |
| labels: | | |
| org.opencontainers.image.authors=${{ github.repository_owner }} | |
| org.opencontainers.image.created=${{ env.BUILD_DATE }} | |
| org.opencontainers.image.description=Created from commit ${{ env.GIT_SHA }} and ref ${{ env.GIT_REF }} | |
| org.opencontainers.image.ref.name=${{ env.GIT_REF }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
| org.opencontainers.image.version=${{ env.BUILD_VER }} | |