From 1822caa3127445f96135b91434af770fdb1a22ad Mon Sep 17 00:00:00 2001 From: David Siaw Date: Fri, 7 Jun 2024 11:09:17 +0900 Subject: [PATCH] Automatically push docker containers (#99) * automatically push docker containers * fix branchane, --- .github/workflows/docker-branch-build.yml | 24 +++++++++++++++++++++++ .github/workflows/docker.yml | 24 +++++++++++++++++++++++ README.md | 4 ++-- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/docker-branch-build.yml create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker-branch-build.yml b/.github/workflows/docker-branch-build.yml new file mode 100644 index 00000000..7c4757dc --- /dev/null +++ b/.github/workflows/docker-branch-build.yml @@ -0,0 +1,24 @@ +name: docker-branch-build +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: extract_branch + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: degicadev + password: ${{ secrets.DOCKERHUB_PAT }} + - name: setup + run: |- + docker build . -t degicadev/kaiser:branch-${{ steps.extract_branch.outputs.branch }} + docker push degicadev/kaiser:branch-${{ steps.extract_branch.outputs.branch }} + +'on': + push: + branches: + - '*' diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..3a127607 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,24 @@ +--- +name: docker +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: degicadev + password: ${{ secrets.DOCKERHUB_PAT }} + - name: setup + run: |- + docker build . -t degicadev/kaiser:latest + docker push degicadev/kaiser:latest + docker build . -t degicadev/kaiser:`bin/version` + docker push degicadev/kaiser:`bin/version` + +'on': + push: + branches: + - 'master' \ No newline at end of file diff --git a/README.md b/README.md index 2de64778..69ad582b 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,14 @@ docker build -t degica/kaiser . And then add the following line to your `.bashrc` or `.bash_profile` ``` -alias kaiser='docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v `pwd`:`pwd` -e CONTEXT_DIR="`pwd`" degica/kaiser' +alias kaiser='docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v `pwd`:`pwd` -e CONTEXT_DIR="`pwd`" degicadev/kaiser' ``` Or if you use fish ``` function kaiser - docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v (pwd):(pwd) -e CONTEXT_DIR=(pwd) degica/kaiser $argv + docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v (pwd):(pwd) -e CONTEXT_DIR=(pwd) degicadev/kaiser $argv end ```