-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: miigotu <[email protected]> Cache docker layers Signed-off-by: miigotu <[email protected]>
- Loading branch information
Showing
2 changed files
with
95 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
ShellCheck: | ||
name: Shellcheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: ShellCheck Depends | ||
uses: ludeeus/action-shellcheck@master | ||
Docker: | ||
name: Docker | ||
runs-on: ubuntu-latest | ||
needs: ShellCheck | ||
steps: | ||
- name: Checkout | ||
if: success() | ||
id: checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up QEMU | ||
if: success() | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
if: success() | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Prepare | ||
if: success() | ||
id: prepare | ||
run: | | ||
echo ::set-output name=docker_platforms::linux/amd64,linux/386 | ||
echo ::set-output name=docker_username::miigotu | ||
echo ::set-output name=github_image::${{ steps.prepare.outputs.github_image }} | ||
VERSION_TAG=${GITHUB_REF#refs/*/} | ||
echo ::set-output name=version::${VERSION_TAG%/merge} | ||
# - name: Login to DockerHub | ||
# if: success() | ||
# id: login_docker | ||
# uses: docker/login-action@v1 | ||
# with: | ||
# username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
# password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Login to GitHub Container Registry | ||
if: success() | ||
id: login_github | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ steps.prepare.outputs.docker_username }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push (master) | ||
if: success() && steps.prepare.outputs.version == 'master' && github.event_name != 'pull_request' | ||
id: build_push_master | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
platforms: ${{ steps.prepare.outputs.docker_platforms }} | ||
push: true | ||
tags: | | ||
${{ steps.prepare.outputs.github_image }}:master | ||
${{ steps.prepare.outputs.github_image }}:latest | ||
- name: Build and push (development) | ||
if: success() && steps.prepare.outputs.version != 'master' && github.event_name != 'pull_request' | ||
id: build_push_development | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
platforms: ${{ steps.prepare.outputs.docker_platforms }} | ||
push: true | ||
tags: | | ||
${{ steps.prepare.outputs.github_image }}:${{ steps.prepare.outputs.version }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
- name: Move cache | ||
# Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
This file was deleted.
Oops, something went wrong.