Skip to content

Commit

Permalink
Improve GitHub Actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed May 28, 2022
1 parent 364eb23 commit 6d12b4f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
32 changes: 28 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down

0 comments on commit 6d12b4f

Please sign in to comment.