Skip to content

Commit

Permalink
refactor(.github/workflows/staging-build.yaml): replace build job wit…
Browse files Browse the repository at this point in the history
…h call-docker-build action for code reusability

The build job in the staging-build.yaml workflow has been replaced with
the call-docker-build action. This change was made to promote code
reusability and maintainability. Now, the docker build and push process
is defined in a single place and can be reused across different
workflows.
  • Loading branch information
cybersiddhu committed Apr 15, 2024
1 parent 0f1490d commit 6e2709d
Showing 1 changed file with 6 additions and 36 deletions.
42 changes: 6 additions & 36 deletions .github/workflows/staging-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,9 @@ on:
branches:
- staging
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: set up golang
uses: actions/setup-go@v5
with:
go-version: 1.16.5
- name: check out code
uses: actions/checkout@v4
- name: set up docker buildx
uses: docker/setup-buildx-action@v3
- name: cache docker layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: log into dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: get short sha
id: vars
run: |
sha=$(git rev-parse --short HEAD)
echo ::set-output name=image_tag::${sha}
- name: docker build and push
uses: docker/build-push-action@v5
with:
push: true
file: build/package/Dockerfile
tags: dictybase/${{ github.event.repository.name }}:staging-${{ steps.vars.outputs.image_tag }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
call-docker-build:
uses: dictyBase/workflows/.github/workflows/docker-build-push.yaml@develop
secrets: inherit
with:
repository: ${{ github.repository }}
ref: ${{ github.ref_name }}

0 comments on commit 6e2709d

Please sign in to comment.