diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..e0ee27f --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,45 @@ +name: docker + +on: + pull_request: + branches: + - master + push: + branches: + - master + tags: + - v* + +jobs: + release: + runs-on: ubuntu-latest + steps: + - + name: Set TAG_NAME + if: startsWith(github.ref, 'refs/tags/') + run: | + echo "##[set-env name=TAG_NAME;]${GITHUB_REF#refs/tags/}" + - + name: Checkout + uses: actions/checkout@v1 + - + name: Docker Build + run: | + docker build \ + --build-arg "VERSION=${TAG_NAME}" \ + --tag "crazymax/ghaction-github-pages:${TAG_NAME}" \ + --tag "crazymax/ghaction-github-pages:latest" \ + --file Dockerfile . + - + name: Docker Login + if: success() && startsWith(github.ref, 'refs/tags/v') + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin + - + name: Docker Push + if: success() && startsWith(github.ref, 'refs/tags/v') + run: | + docker push crazymax/ghaction-github-pages diff --git a/Dockerfile b/Dockerfile index b02e927..c873621 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,15 @@ FROM alpine/git:latest +ARG VERSION + # https://help.github.com/en/articles/metadata-syntax-for-github-actions#about-yaml-syntax-for-github-actions -LABEL version="0.1.0" \ +LABEL version="$VERSION" \ repository="https://github.com/crazy-max/ghaction-github-pages" \ homepage="https://github.com/crazy-max/ghaction-github-pages" \ maintainer="CrazyMax" \ "com.github.actions.name"="GitHub Pages" \ "com.github.actions.description"="GitHub Action for deploying GitHub Pages" \ - "com.github.actions.icon"="package" \ + "com.github.actions.icon"="upload-cloud" \ "com.github.actions.color"="green" COPY LICENSE README.md / diff --git a/README.md b/README.md index 0ef7f19..78cdd7e 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,19 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` +Docker :whale: image is also provided and automatically updated within [Docker Hub](https://hub.docker.com/u/crazymax/ghaction-github-pages) so you can directly use the following [DockerHub action](https://help.github.com/en/articles/workflow-syntax-for-github-actions#example-using-a-docker-hub-action): + +```yaml +- name: Deploy + if: success() + uses: docker://crazymax/ghaction-github-pages + with: + target_branch: gh-pages + build_dir: public + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +``` + ## 💅 Customizing ### inputs