diff --git a/.dockerignore b/.dockerignore index 12518b7..d8e36ec 100644 --- a/.dockerignore +++ b/.dockerignore @@ -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 diff --git a/.gitattributes b/.gitattributes index f4f1efa..17a9c90 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,5 +3,4 @@ /.editorconfig export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.travis.yml export-ignore /Makefile export-ignore diff --git a/.github/settings.yml b/.github/settings.yml index 7af721e..c7cb3a6 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -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 diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml new file mode 100644 index 0000000..23182d9 --- /dev/null +++ b/.github/workflows/continuous-deployment.yml @@ -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 diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 7f3610e..d3f568f 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -2,7 +2,6 @@ on: - pull_request - - push name: "Continuous Integration" @@ -12,35 +11,18 @@ jobs: runs-on: ubuntu-latest + env: + DOCKER_IMAGE: localheinz/composer-normalize-action + 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 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index fd56137..f47e06e 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -3,7 +3,7 @@ name: "Close stale issues and pull requests" on: schedule: - - cron: "0 * * * *" + - cron: "0 12 * * *" jobs: stale: diff --git a/Makefile b/Makefile index ef78557..7648c0a 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ .PHONY: docker help it +DOCKER_IMAGE:=localheinz/composer-normalize-action + 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}' diff --git a/bin/tag-name.sh b/bin/tag-name.sh new file mode 100755 index 0000000..55b1611 --- /dev/null +++ b/bin/tag-name.sh @@ -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;