Skip to content

Commit

Permalink
Add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
RollerKnobster committed Jun 24, 2021
1 parent 3878591 commit 5fc5d0a
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI
on:
push:
branches:
- main

env:
DOCKER_USERNAME: thedoorknobster
REPO: thedoorknobster/sample-app

jobs:
docker:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Fetch all commits
fetch-depth: 0

- name: Semantic versioning
id: versioning
uses: PaulHatch/[email protected]
with:
branch: main
tag_prefix: "v"
major_pattern: "BREAKING CHANGE:"
minor_pattern: "feat:"
format: "v${major}.${minor}.${patch}-prerelease${increment}"

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ env.REPO }}:latest,${{ env.REPO }}:${{ steps.versioning.outputs.version }}

- name: Create Release
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
tag_name: ${{ steps.versioning.outputs.version }}
release_name: ${{ steps.versioning.outputs.version }}
prerelease: true
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: release
on:
push:
tags:
- 'v*'

env:
DOCKER_USERNAME: thedoorknobster
REPO: thedoorknobster/sample-app

jobs:
docker:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Fetch all commits
fetch-depth: 0

- name: Set environment variables
run: |
cat >> $GITHUB_ENV << EOF
VERSION=${GITHUB_REF##*/}
EOF
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ env.REPO }}:latest,${{ env.REPO }}:${{ env.VERSION }}

0 comments on commit 5fc5d0a

Please sign in to comment.