diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff8779bd7..b61bbd502 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,10 +49,7 @@ jobs: - name: Vet run: make vet docker: - name: Docker - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v4 - - name: Docker - run: make docker_build + name: Docker + needs: [build, test, vet] + uses: ./.github/workflows/docker.yaml + secrets: inherit diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 000000000..062afbb03 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,43 @@ +name: Docker +on: + workflow_call: + workflow_dispatch: +jobs: + docker_build: + name: Build Docker image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Set up Docker QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: amd64,arm64 + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/owenthereal/upterm/uptermd + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=sha,prefix=,suffix=,format=long + - name: Docker build and push + uses: docker/build-push-action@v5 + with: + push: ${{ startsWith(github.ref, 'refs/tags/v') }} + pull: true + file: Dockerfile.uptermd + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: | + type=gha + cache-to: | + type=gha,mode=max diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1376cdc72..0b2fa6413 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,9 +3,14 @@ on: push: tags: 'v*' jobs: - release: + docker: + name: Docker + uses: ./.github/workflows/docker.yaml + secrets: inherit + gorelease: name: Upload releases runs-on: ubuntu-latest + needs: [docker] steps: - uses: actions/checkout@v4 - name: Set up Go @@ -20,16 +25,10 @@ jobs: args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - name: Docker push on master - run: | - # Build & publish on master - echo "${{ secrets.GH_TOKEN }}" | docker login ghcr.io -u USERNAME --password-stdin - TAG=${GITHUB_REF_NAME} make docker_push - TAG=latest make docker_push deploy: name: Deploy app runs-on: ubuntu-latest - needs: [release] + needs: [gorelease] steps: - uses: actions/checkout@v4 - uses: superfly/flyctl-actions/setup-flyctl@master