tweaking GH Actions #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Docker Build | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout branch | |
uses: actions/checkout@v4 | |
- | |
name: Docker Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- | |
name: Docker Setup Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- | |
name: Build and push Docker images | |
uses: docker/[email protected] | |
with: | |
push: false | |
load: true | |
tags: contrastsecuritydemo/netflicks:latest-agent | |
test: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- | |
run: | | |
echo Testing now | |
- | |
name: Checkout branch | |
uses: actions/checkout@v4 | |
- | |
name: Run docker-compose tests | |
run: | | |
docker-compose up -d | |
- | |
name: Setup Node | |
uses: actions/setup-node@v3 | |
- | |
name: Install dependencies | |
run: | | |
cd e2e | |
npm install | |
npx playwright install | |
- | |
name: Install playwright browsers | |
run: | | |
cd e2e | |
npx playwright install-deps chromium | |
- | |
name: Run tests | |
run: | | |
cd e2e | |
npx playwright test | |
pre-merge: | |
name: Prepare to merge | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
steps: | |
- name: Docker Metadata action | |
id: metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: contrastsecuritydemo/netflicks | |
flavor: | | |
latest=true | |
suffix=agent | |
tags: | | |
type=semver,pattern={{version}}, priority=100 | |
type=semver,pattern={{major}}.{{minor}}, priority=200 | |
- name: Version number | |
run: | | |
echo Getting the old build number | |
echo $(echo ${{ steps.metadata.outputs.tags }}) | |
merge: | |
name: Merge if PR is merged and tests pass | |
if: github.event.pull_request.merged | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- test | |
steps: | |
- run: | | |
echo The PR was merged |