Skip to content

Commit

Permalink
fix: update github flow
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
  • Loading branch information
gfanton committed Apr 10, 2024
1 parent 1b5a540 commit 6a6371d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 49 deletions.
107 changes: 58 additions & 49 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,69 +14,78 @@ concurrency:
cancel-in-progress: true

jobs:
build-push:
build-main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build main Docker image
env:
owner: ${{ github.repository_owner }}
reponame: ${{ github.event.repository.name }}
run: |
docker build -t ghcr.io/${owner}/${reponame} .
docker tag ghcr.io/${owner}/${reponame}:latest ghcr.io/${owner}/${reponame}:${GITHUB_SHA::8}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build slim Docker images
env:
owner: ${{ github.repository_owner }}
reponame: ${{ github.event.repository.name }}
run: |
docker build --target=gnoland-slim -t ghcr.io/${owner}/${reponame}/gnoland-slim .
docker build --target=gnokey-slim -t ghcr.io/${owner}/${reponame}/gnokey-slim .
docker build --target=gno-slim -t ghcr.io/${owner}/${reponame}/gno-slim .
docker build --target=gnofaucet-slim -t ghcr.io/${owner}/${reponame}/gnofaucet-slim .
docker build --target=gnoweb-slim -t ghcr.io/${owner}/${reponame}/gnoweb-slim .
docker tag ghcr.io/${owner}/${reponame}/gnoland-slim:latest ghcr.io/${owner}/${reponame}/gnoland-slim:${GITHUB_SHA::8}
docker tag ghcr.io/${owner}/${reponame}/gnokey-slim:latest ghcr.io/${owner}/${reponame}/gnokey-slim:${GITHUB_SHA::8}
docker tag ghcr.io/${owner}/${reponame}/gno-slim:latest ghcr.io/${owner}/${reponame}/gno-slim:${GITHUB_SHA::8}
docker tag ghcr.io/${owner}/${reponame}/gnofaucet-slim:latest ghcr.io/${owner}/${reponame}/gnofaucet-slim:${GITHUB_SHA::8}
docker tag ghcr.io/${owner}/${reponame}/gnoweb-slim:latest ghcr.io/${owner}/${reponame}/gnoweb-slim:${GITHUB_SHA::8}
- name: List docker images
run: |
docker images | grep ghcr
- name: Log in to GitHub Container Registry
if: (github.event_name != 'pull_request')
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: (github.event_name != 'pull_request')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: "${{ github.event_name != 'pull_request' }}"
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${GITHUB_SHA::8}
- name: Publish images
if: (github.event_name != 'pull_request')
env:
owner: ${{ github.repository_owner }}
reponame: ${{ github.event.repository.name }}
run: |
docker push ghcr.io/${owner}/${reponame}:latest
docker push ghcr.io/${owner}/${reponame}:${GITHUB_SHA::8}
# - name: Build main Docker image
# env:
# owner: ${{ github.repository_owner }}
# reponame: ${{ github.event.repository.name }}
# platform: linux/arm64,linux/amd64
# run: |
# docker buildx build \
# -t ghcr.io/${owner}/${reponame}
# --platform ${platform} \
# --tag ghcr.io/${owner}/${reponame}:latest \
# --tag ghcr.io/${owner}/${reponame}:${GITHUB_SHA::8} \
# .

docker push ghcr.io/${owner}/${reponame}/gnoland-slim:latest
docker push ghcr.io/${owner}/${reponame}/gnoland-slim:${GITHUB_SHA::8}
# docker tag ghcr.io/${owner}/${reponame}:latest ghcr.io/${owner}/${reponame}:${GITHUB_SHA::8}

docker push ghcr.io/${owner}/${reponame}/gnokey-slim:latest
docker push ghcr.io/${owner}/${reponame}/gnokey-slim:${GITHUB_SHA::8}
build-slim:
runs-on: ubuntu-latest
strategy:
matrix:
target: [gnoland, gnoland-slim, gnokey-slim, gno-slim, gnofaucet-slim, gnoweb-slim]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

docker push ghcr.io/${owner}/${reponame}/gno-slim:latest
docker push ghcr.io/${owner}/${reponame}/gno-slim:${GITHUB_SHA::8}

docker push ghcr.io/${owner}/${reponame}/gnofaucet-slim:latest
docker push ghcr.io/${owner}/${reponame}/gnofaucet-slim:${GITHUB_SHA::8}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

docker push ghcr.io/${owner}/${reponame}/gnoweb-slim:latest
docker push ghcr.io/${owner}/${reponame}/gnoweb-slim:${GITHUB_SHA::8}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: (github.event_name != 'pull_request')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/${{ matrix.target }}:latest
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/${{ matrix.target }}:${{GITHUB_SHA::8}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ WORKDIR /opt/build
ADD go.mod go.sum ./
RUN go mod download
ADD . ./
ENV CGO_ENABLED=0
RUN go build -o ./build/gnoland ./gno.land/cmd/gnoland
RUN go build -o ./build/gnokey ./gno.land/cmd/gnokey
RUN go build -o ./build/gnofaucet ./gno.land/cmd/gnofaucet
Expand Down

0 comments on commit 6a6371d

Please sign in to comment.