Skip to content

Commit

Permalink
chore: use marketplace's docker build-and-push action
Browse files Browse the repository at this point in the history
  • Loading branch information
Semior001 committed Mar 11, 2024
1 parent 3c486ee commit c287c58
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions .github/workflows/.go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
steps:
- name: set up go 1.22.0
uses: actions/setup-go@v4
id: go
with: { go-version: 1.22.0 }

- name: checkout
Expand Down Expand Up @@ -50,36 +49,33 @@ jobs:
uses: docker/setup-qemu-action@v1

- name: set up Docker Buildx
id: buildx
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}
uses: docker/setup-buildx-action@v1

- name: login, build and deploy master image to ghcr.io
- name: login to ghcr
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: build and deploy master image to ghcr
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v5
env:
GHCR_USERNAME: ${{ github.actor }}
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GHCR_PASSWORD} | docker login ghcr.io -u ${GHCR_USERNAME} --password-stdin
docker buildx build --push \
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/semior001/groxy:${ref} .
with:
push: true
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: ghcr.io/semior001/groxy:master,ghcr.io/semior001/groxy:$GITHUB_SHA

- name: login, build and deploy tagged (latest) to ghcr.io
- name: build and deploy tagged (latest) image to ghcr
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: docker/build-push-action@v5
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GHCR_PASSWORD} | docker login ghcr.io -u ${GHCR_USERNAME} --password-stdin
docker buildx build --push \
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/semior001/groxy:${ref} -t ghcr.io/semior001/groxy:latest .
with:
push: true
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: ghcr.io/semior001/groxy:latest,ghcr.io/semior001/groxy:${{ github.ref }}

0 comments on commit c287c58

Please sign in to comment.