diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 005ecdc..3094dbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,27 +104,51 @@ jobs: name: Docker Build Check runs-on: ubuntu-latest - needs: Hadolint + needs: [Hadolint, Shellcheck, Aligo] + + env: + DOCKER_FILE: Dockerfile + IMAGE_NAME: bop steps: + - name: Check event type + run: | + if [[ "${{github.event_name}}" != "pull_request" ]] ; then + echo "::notice::Event type is not 'pull_request', all job actions will be skipped" + fi + + # This step is a hack for needs+if issue with actions + # More info about issue: https://github.com/actions/runner/issues/491 + - name: Checkout uses: actions/checkout@v3 + if: ${{ github.event_name == 'pull_request' }} - name: Login to DockerHub uses: docker/login-action@v2 env: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - if: ${{ env.DOCKERHUB_USERNAME != '' }} + if: ${{ github.event_name == 'pull_request' && env.DOCKERHUB_USERNAME != '' }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + if: ${{ github.event_name == 'pull_request' }} + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build Docker image + if: ${{ github.event_name == 'pull_request' }} run: | - docker build -f Dockerfile -t bop . + docker build -f ${{ env.DOCKER_FILE }} -t ${{ env.IMAGE_NAME }} . - name: Show info about built Docker image uses: essentialkaos/docker-info-action@v1 + if: ${{ github.event_name == 'pull_request' }} with: - image: bop + image: ${{ env.IMAGE_NAME }} show-labels: true diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index 6e30210..fa04ca6 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -37,6 +37,21 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout the latest tag + run: | + rev=$(git rev-list --tags --max-count=1) + tag=$(git describe --tags "$rev") + + if [[ -z "$tag" ]] ; then + echo "::error::Can't find the latest tag" + exit 1 + fi + + echo -e "\033[34mRev:\033[0m $rev" + echo -e "\033[34mTag:\033[0m $tag" + + git checkout "$tag" + - name: Prepare metadata for build id: metadata run: |