Skip to content

Commit

Permalink
Docker Hub push when release (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkurzyniec authored May 25, 2024
1 parent 974c159 commit 9060f0d
Show file tree
Hide file tree
Showing 81 changed files with 3,123 additions and 3,046 deletions.
18 changes: 9 additions & 9 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
**/bin/
**/obj/
**/*.user

.*/

db
test
src/HappyCode.NetCoreBoilerplate.Db
**/bin/
**/obj/
**/*.user

.*/

db
test
src/HappyCode.NetCoreBoilerplate.Db
56 changes: 28 additions & 28 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
; Top-most EditorConfig file
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

[*.{bat,cmd}]
insert_final_newline = false

[*.cs]
indent_size = 4

dotnet_sort_system_directives_first = true

# private fields with underscore prefix => private int _myValue;
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
dotnet_naming_rule.private_members_with_underscore.severity = suggestion

dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

dotnet_naming_style.prefix_underscore.capitalization = camel_case
dotnet_naming_style.prefix_underscore.required_prefix = _
; Top-most EditorConfig file
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

[*.{bat,cmd}]
insert_final_newline = false

[*.cs]
indent_size = 4

dotnet_sort_system_directives_first = true

# private fields with underscore prefix => private int _myValue;
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
dotnet_naming_rule.private_members_with_underscore.severity = suggestion

dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

dotnet_naming_style.prefix_underscore.capitalization = camel_case
dotnet_naming_style.prefix_underscore.required_prefix = _
20 changes: 10 additions & 10 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Contribution

You are very welcome to submit either issues or pull requests to this repository!

For pull request please follow this rules:

* Commit messages should be clear and as much as possible descriptive.
* Rebase if required.
* Make sure that your code compile and run locally.
* Changes do not break any tests and code quality rules.
# Contribution

You are very welcome to submit either issues or pull requests to this repository!

For pull request please follow this rules:

* Commit messages should be clear and as much as possible descriptive.
* Rebase if required.
* Make sure that your code compile and run locally.
* Changes do not break any tests and code quality rules.
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
custom: ["https://www.buymeacoffee.com/lkurzyniec"]
---
custom: ["https://www.buymeacoffee.com/lkurzyniec"]
22 changes: 11 additions & 11 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"

- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "weekly"
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"

- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "weekly"
49 changes: 49 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: Docker build

on:
push:
paths-ignore:
- '**.md'
workflow_dispatch:
workflow_call:

env:
BASE_TAG: lkurzyniec/netcore-boilerplate

jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest

steps:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build docker image
uses: docker/build-push-action@v5
with:
load: true
tags: ${{ env.BASE_TAG }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Test container
run: |
docker run -d --rm -p 5000:8080 ${{ env.BASE_TAG }}:latest
echo "Taking a short nap..."
sleep 5s
echo "Checking health check endpoint..."
curl -Is http://localhost:5000/health | head -n 1
HTTP_CODE=$(curl -o /dev/null -s -w "%{http_code}\n" http://localhost:5000/health)
echo "HTTP_CODE=$HTTP_CODE" >> $GITHUB_OUTPUT
# echo "Validating response..."
# if [ "$HTTP_CODE" = "200" ]; then
# echo "All is valid!"
# else
# echo "Response is invalid!"
# exit 1
# fi
53 changes: 53 additions & 0 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: Docker push

on:
release:
types: [published]

env:
BASE_TAG: lkurzyniec/netcore-boilerplate

jobs:
build-and-test:
name: Build and Test
uses: ./.github/workflows/docker-build.yml

push:
name: Push to Docker Hub
runs-on: ubuntu-latest
needs: build-and-test
environment: docker
concurrency: docker
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
github.ref_type == 'tag'
# && needs.build-and-test.outputs.HTTP_CODE == 200

steps:
- name: Grab a version
run: |
version="{{ github.ref }}"
version="${version/refs\/tags\/v/}"
echo "Version: ${version}"
echo "### Version ${version} published! :rocket:" >> $GITHUB_STEP_SUMMARY
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: |
${{ env.BASE_TAG }}:latest
${{ env.BASE_TAG }}:${{ env.VERSION }}
23 changes: 0 additions & 23 deletions .github/workflows/docker.yml

This file was deleted.

Loading

0 comments on commit 9060f0d

Please sign in to comment.