Skip to content

Commit

Permalink
fix: Change workflow (#12)
Browse files Browse the repository at this point in the history
* fix: Change workflow

Signed-off-by: Martin Buchleitner <mbuchleitner@infralovers.com>

* fix: udpate matrix strategy

Signed-off-by: Martin Buchleitner <mbuchleitner@infralovers.com>

---------

Signed-off-by: Martin Buchleitner <mbuchleitner@infralovers.com>
  • Loading branch information
mabunixda authored May 8, 2024
1 parent f49690f commit 35cd998
Showing 1 changed file with 17 additions and 123 deletions.
140 changes: 17 additions & 123 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,136 +2,30 @@ name: Infralovers Container Build

on:
push:
branches: [ 'main' ]
branches: [ main ]

pull_request:
branches: [ 'main' ]
branches: [ main ]

jobs:
prebuild:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.semrel.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Check pre-commit presence
id: precommit_exists
uses: andstor/file-existence-action@v1
with:
files: ".pre-commit-config.yaml"
- uses: actions/setup-python@v3
if: steps.precommit_exists.outputs.files_exists == 'true'
- uses: pre-commit/action@v3.0.0
if: steps.precommit_exists.outputs.files_exists == 'true'
- uses: go-semantic-release/action@v1
if: github.event_name != 'pull_request'
id: semrel
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
prepend: true
dry: true

build:
strategy:
matrix:
baseimage: [ standalone-chrome, standalone-firefox ]
baseversion: [ 4.18 ]
runs-on: ubuntu-latest
needs: [ prebuild ]
steps:
- uses: actions/checkout@v2

- name: Prepare tagging
id: prep
run: |
IMAGE_NAME="${{ matrix.baseimage }}-behave"
IMAGE_REPO=${{ github.repository_owner }}
if [[ -n "${{ secrets.IMAGE_NAME }}" ]]; then
IMAGE_NAME="${{ secrets.IMAGE_NAME }}"
fi
if [[ -n "${{ secrets.IMAGE_REPO }}" ]]; then
IMAGE_REPO="${{ secrets.IMAGE_REPO }}"
fi
QUAY_IMAGE="quay.io/$IMAGE_REPO/$IMAGE_NAME"
GHCR_IMAGE="ghcr.io/${{ github.repository }}"
VERSION="${{ matrix.baseversion }}-dev"
if [[ '${{ needs.prebuild.outputs.version }}' != '' ]]; then
VERSION="${{ matrix.baseversion }}"
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION="${{ matrix.baseversion }}-nightly"
fi
TAGS="${QUAY_IMAGE}:${VERSION},${GHCR_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${QUAY_IMAGE}:latest,${GHCR_IMAGE}:latest"
fi
echo "settings tag ${TAGS}"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64,arm,amd64'

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Quay
if: needs.prebuild.outputs.version != ''
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Login to GitHub Container Registry
if: needs.prebuild.outputs.version != ''
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.BOT_ACCESS_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' && needs.prebuild.outputs.version != '' }}
tags: ${{ steps.prep.outputs.tags }}
platforms: 'arm64,arm,amd64'
build-args: |
SELENIUM_BASE=docker.io/selenium/${{ matrix.baseimage }}:${{ matrix.baseversion }}
release:
needs: [ prebuild, build ]
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- uses: go-semantic-release/action@v1
if: needs.prebuild.outputs.version != ''
id: generate_changelog
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
prepend: true
changelog-file: CHANGELOG.md

- name: Update changelog
uses: stefanzweifel/git-auto-commit-action@v4
if: steps.generate_changelog.outputs.version != ''
with:
commit_message: 'chore(ci): commit changes from go-semantic-release'
file_pattern: CHANGELOG.md
uses: infralovers/.github/.github/workflows/container.yml@container-build-args
secrets:
QUAY_USER: "${{ fromJSON(secrets.VAULT_KV_1D187965_OP_QUAY_ROBOT_ACCOUNT).username }}"
QUAY_TOKEN: "${{ fromJSON(secrets.VAULT_KV_1D187965_OP_QUAY_ROBOT_ACCOUNT).password }}"
BOT_ACCESS_TOKEN: "${{ fromJSON(secrets.VAULT_KV_1D187965_OP_GITHUB_INFRALOVERS).PAT }}"
MONDOO_SERVICE_ACCOUNT: "${{ fromJson(secrets.VAULT_KV_1D187965_OP_MONDOO_PACKER_AGENT).password }}"
with:
dockerfile: Dockerfile
score: 50
platforms: "linux/amd64, linux/arm64"
release: true
image_name: "${{matrix.baseimage}}-behave"
build_args: |
SELENIUM_BASE=docker.io/selenium/${{ matrix.baseimage }}:${{ matrix.baseversion }}

0 comments on commit 35cd998

Please sign in to comment.