Skip to content

Commit

Permalink
Use Docker GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
owenthereal committed May 21, 2024
1 parent 540df7e commit 0fe8653
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 15 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
43 changes: 43 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 7 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0fe8653

Please sign in to comment.