Skip to content
This repository has been archived by the owner on Mar 6, 2021. It is now read-only.

Commit

Permalink
Enhancement: Synchronize with ergebnis/github-action-template
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 9, 2019
1 parent 48e4e95 commit 8d89aa1
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 39 deletions.
21 changes: 11 additions & 10 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.build/
.github/
.editorconfig
.gitattributes
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
Makefile
README.md
/.build/
/.git/
/.github/
/bin/
/.editorconfig
/.gitattributes
/.gitignore
/CHANGELOG.md
/LICENSE
/Makefile
/README.md
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/Makefile export-ignore
9 changes: 9 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@ labels:
- name: bug
color: ee0701

- name: dependency
color: 0366d6

- name: enhancement
color: 0e8a16

- name: question
color: cc317c

- name: security
color: ee0701

- name: stale
color: eeeeee

Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

on:
push:
branches:
- master
tags:
- "**"

name: "Continuous Deployment"

jobs:
build:
name: "Build and deploy"

runs-on: ubuntu-latest

env:
DOCKER_IMAGE: localheinz/composer-normalize-action

steps:
- name: "Checkout"
uses: actions/checkout@v1

- name: "Build Docker image"
run: $(which docker) build --tag ${DOCKER_IMAGE}:latest .

- name: "Docker Login"
if: "'refs/heads/master' == github.ref || startsWith(github.ref, 'refs/tags/')"
run: echo ${{ secrets.DOCKER_PASSWORD }} | $(which docker) login --password-stdin --username ${{ secrets.DOCKER_USERNAME }}

- name: "Push Docker image (latest)"
if: "'refs/heads/master' == github.ref || startsWith(github.ref, 'refs/tags/')"
run: $(which docker) push ${DOCKER_IMAGE}:latest

- name: "Tag Docker image (versioned)"
if: "startsWith(github.ref, 'refs/tags/')"
run: $(which docker) tag ${DOCKER_IMAGE} ${DOCKER_IMAGE}:$(bash ./bin/tag-name.sh ${GITHUB_REF})

- name: "Push Docker image (versioned)"
if: "startsWith(github.ref, 'refs/tags/')"
run: $(which docker) push ${DOCKER_IMAGE}:$(bash ./bin/tag-name.sh ${GITHUB_REF})

- name: "Docker Logout"
if: "'refs/heads/master' == github.ref || startsWith(github.ref, 'refs/tags/')"
run: $(which docker) logout
32 changes: 7 additions & 25 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

on:
- pull_request
- push

name: "Continuous Integration"

Expand All @@ -12,35 +11,18 @@ jobs:

runs-on: ubuntu-latest

env:
DOCKER_IMAGE: ergebnis/github-action-template

steps:
- name: "Checkout"
uses: actions/checkout@master
uses: actions/checkout@v1

- name: "Build Docker image"
run: $(which docker) build --tag localheinz/composer-normalize-action ${GITHUB_WORKSPACE}
run: $(which docker) build --tag ${DOCKER_IMAGE}:latest .

- name: "Run Docker image with default behaviour"
run: $(which docker) run --interactive --rm --workdir=/normalizer --volume ${GITHUB_WORKSPACE}/.build:/normalizer localheinz/composer-normalize-action:latest
run: $(which docker) run --interactive --rm --workdir=/app --volume ${GITHUB_WORKSPACE}/.build:/app localheinz/composer-normalize-action:latest

- name: "Run Docker image with custom behaviour"
run: $(which docker) run --interactive --rm --workdir=/normalizer --volume ${GITHUB_WORKSPACE}/.build:/normalizer localheinz/composer-normalize-action:latest --indent-size=1 --indent-style=tab --no-update-lock

- name: "Docker Login"
if: "'refs/heads/master' == github.ref || startsWith(github.ref, 'refs/tags/')"
run: echo ${{ secrets.DOCKER_PASSWORD }} | $(which docker) login --password-stdin --username ${{ secrets.DOCKER_USERNAME }}

- name: "Push Docker image (latest)"
if: "'refs/heads/master' == github.ref || startsWith(github.ref, 'refs/tags/')"
run: $(which docker) push localheinz/composer-normalize-action:latest

- name: "Tag Docker image (versioned)"
if: "startsWith(github.ref, 'refs/tags/')"
run: $(which docker) tag localheinz/composer-normalize-action localheinz/composer-normalize-action:$(bash ./.build/tag-name.sh ${GITHUB_REF})

- name: "Push Docker image (versioned)"
if: "startsWith(github.ref, 'refs/tags/')"
run: $(which docker) push localheinz/composer-normalize-action:$(bash ./.build/tag-name.sh ${GITHUB_REF})

- name: "Docker Logout"
if: "'refs/heads/master' == github.ref || startsWith(github.ref, 'refs/tags/')"
run: $(which docker) logout
run: $(which docker) run --interactive --rm --workdir=/app --volume ${GITHUB_WORKSPACE}/.build:/app localheinz/composer-normalize-action:latest --indent-size=1 --indent-style=tab --no-update-lock
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name: "Close stale issues and pull requests"
on:
schedule:
- cron: "0 * * * *"
- cron: "0 12 * * *"

jobs:
stale:
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.PHONY: docker help it

DOCKER_IMAGE:=ergebnis/github-action-template

it: docker ## Runs the docker target

docker: ## Builds, tags, and runs the Docker image
docker build --tag localheinz/composer-normalize-action .
docker run --interactive --rm --tty --workdir=/normalizer --volume ${PWD}/.build:/normalizer localheinz/composer-normalize-action:latest
docker build --tag ${DOCKER_IMAGE} .
docker run --interactive --rm --tty --workdir=/app --volume ${PWD}:/app ${DOCKER_IMAGE}:latest

help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
13 changes: 13 additions & 0 deletions bin/tag-name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

GITHUB_REF=$1

if [[ -n $GITHUB_REF && $GITHUB_REF == refs/tags/* ]]; then
echo "${GITHUB_REF#refs/tags/}";

exit 0
fi

echo "Unable to determine tag name from '${GITHUB_REF}'"

exit 1;

0 comments on commit 8d89aa1

Please sign in to comment.