Skip to content

Commit

Permalink
Merge pull request #110 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 1fdbf1f + a5542ff commit a5de44c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
33 changes: 30 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,49 @@ jobs:

needs: [Hadolint, Shellcheck, Perfecto]

env:
DOCKER_FILE: centos7.docker
IMAGE_NAME: centos7

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: ${{ github.event_name == 'pull_request' && env.DOCKERHUB_USERNAME != '' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build CentOS 7 image
- 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 centos7.docker -t centos7 .
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: centos7
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 a5de44c

Please sign in to comment.