Skip to content

Commit

Permalink
feat: add test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Jul 4, 2024
1 parent 6965dc9 commit e607b14
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0

- name: Set version
# Always use git tags as semantic release can fail due to rate limit
run: |
git fetch --prune --unshallow
echo "RELEASE_VERSION=$(git describe --abbrev=0 --tags | sed -e 's/^v//')" >> $GITHUB_ENV
- name: Set up Docker Buildx #must be executed before a step that contains platforms
uses: docker/setup-buildx-action@v2

- name: Publish minimal image to registry
uses: elgohr/Publish-Docker-Github-Action@8217e91c0369a5342a4ef2d612de87492410a666 # master
with:
Expand All @@ -45,5 +45,5 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}
snapshot: true
dockerfile: Dockerfile
tags: "latest,v${{ env.RELEASE_VERSION }}"
tags: 'latest,v${{ env.RELEASE_VERSION }}'
platforms: linux/amd64,linux/arm64
37 changes: 37 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test Build & Run
on:
pull_request:

permissions:
contents: read

jobs:
docker-build:
needs: semantic-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0

- name: Set version
# Always use git tags as semantic release can fail due to rate limit
run: |
git fetch --prune --unshallow
echo "RELEASE_VERSION=$(git describe --abbrev=0 --tags | sed -e 's/^v//')" >> $GITHUB_ENV
- name: Set up Docker Buildx #must be executed before a step that contains platforms
uses: docker/setup-buildx-action@v2

- name: Build image
uses: elgohr/Publish-Docker-Github-Action@8217e91c0369a5342a4ef2d612de87492410a666 # master
with:
name: flanksource/base-image
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
no_push: true
dockerfile: Dockerfile
tags: 'latest,v${{ env.RELEASE_VERSION }}'
platforms: linux/amd64,linux/arm64

- name: Run the container
run: |
docker run --rm -it flanksource/base-image:v${{ env.RELEASE_VERSION }} exit 0

0 comments on commit e607b14

Please sign in to comment.