name: docker image ci on: push: branches: - master tags: - invalid-tag jobs: test: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@master - name: build if: github.event.deleted == false env: DOCKER_IMAGE: docker.pkg.github.com/${{ github.repository }}/action:latest run: | docker build . --file Dockerfile --tag ${DOCKER_IMAGE} || (echo -e "\e[31m[${GITHUB_WORKFLOW}] failed to build\e[m" && exit 1) - name: push latest image if: success() && endsWith(github.ref, 'master') env: DOCKER_IMAGE: docker.pkg.github.com/${{ github.repository }}/action:latest PKG_GITHUB_TOKEN: ${{ secrets.PKG_GITHUB_TOKEN }} run: | echo ${PKG_GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin && docker push ${DOCKER_IMAGE} && docker logout