Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test build_image workflow #13

Merged
merged 2 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading