Skip to content

Commit

Permalink
Merge pull request #13 from CubicrootXYZ/test-build-image
Browse files Browse the repository at this point in the history
test build_image workflow
  • Loading branch information
CubicrootXYZ authored Oct 20, 2024
2 parents 541a8aa + 8aa96e4 commit 9cc7a18
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
image_name:
required: true
type: string
static_tag:
required: false
type: string
default: ""
secrets:
dockerhub_user:
required: true
Expand Down Expand Up @@ -38,4 +42,10 @@ jobs:
- name: Push image with tag
if: "startsWith(github.ref, 'refs/tags/')"
run: docker push ${{ inputs.image_name }}:${{ github.ref_name }}
- name: Tag image with static tag
if: "${{ inputs.static_tag != '' && github.ref == 'refs/heads/main'}}"
run: docker tag ${{ inputs.image_name }}:${{ github.sha }} ${{ inputs.image_name }}:${{ inputs.static_tag }}
- name: Push image with static tag
if: "${{ inputs.static_tag != '' && github.ref == 'refs/heads/main'}}"
run: docker push ${{ inputs.image_name }}:${{ inputs.static_tag }}

12 changes: 12 additions & 0 deletions .github/workflows/build_image_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on: push

jobs:
build_image_test:
uses: ./.github/workflows/build_image.yaml
with:
docker_file_path: "tests/build_image/"
image_name: cubicrootxyz/workflows-test
static_tag: beta
secrets:
dockerhub_user: "${{ secrets.DOCKERHUB_USERNAME }}"
dockerhub_token: "${{ secrets.DOCKERHUB_TOKEN }}"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Collection of commonly used GitHub workflows.

This workflow will build and push images to Dockerhub. For any change an image with the commit SHA as tag will be published. For releases the release tag will be used to tag the image.

Provide a `static_tag` so any commit on `main` branch will result in an image pushed with that tag. Can be used to provide a `beta` or `main` tagged image.

```yaml
jobs:
build_image:
Expand Down
1 change: 1 addition & 0 deletions tests/build_image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM scratch

0 comments on commit 9cc7a18

Please sign in to comment.