Skip to content

Commit

Permalink
.github: merge ci.yaml and publish_docker.yaml
Browse files Browse the repository at this point in the history
Fix both workflows in a single yaml, such that dockerization
doesn't happen if checks fail.
  • Loading branch information
msune committed Aug 25, 2024
1 parent 07ace94 commit 61f48fa
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 52 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

permissions:
packages: write

env:
PLATFORMS: linux/amd64

jobs:
make_check:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -37,3 +43,43 @@ jobs:
- name: "Run tests..."
run: cd sfunnel/test && make

docker_build_and_publish:
needs: [make_check]
runs-on: ubuntu-22.04
steps:
- name: "Checkout sfunnel"
uses: actions/checkout@v4
with:
path: sfunnel
fetch-depth: 0
fetch-tags: 1

- name: "Set up Docker buildx"
uses: docker/setup-buildx-action@v3

- name: "Login to GitHub Container Registry (ghcr.io)"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}

- name: "Build and push to ghcr"
run: |
#Cross-build
cd sfunnel
echo "Fix mess with tags in actions/checkout..."
git fetch -f && git fetch -f --tags
export TAG=$(git describe HEAD | sed 's/-.*$//g' | tr -d "v")
EXACT_TAG=$(git describe --exact-match --match "v*" || echo "")
if [[ "${EXACT_TAG}" != "" ]]; then
echo "Cross-building and PUSHING!"
docker buildx build --platform ${PLATFORMS} --push -f docker/Dockerfile . --tag ghcr.io/${GITHUB_REPOSITORY}:${TAG}
else
echo "Cross-building ONLY"
docker buildx build --platform ${PLATFORMS} -f docker/Dockerfile .
fi
52 changes: 0 additions & 52 deletions .github/workflows/publish_docker.yaml

This file was deleted.

0 comments on commit 61f48fa

Please sign in to comment.