Skip to content

Commit

Permalink
Merge pull request #17 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Improve GitHub Actions workflows
  • Loading branch information
andyone authored May 28, 2022
2 parents 9bc9b5f + f3e1a6d commit ac8191c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,49 @@ jobs:

needs: Hadolint

env:
DOCKER_FILE: Dockerfile
IMAGE_NAME: rsz

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 rsz .
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: rsz
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 ac8191c

Please sign in to comment.