Skip to content

Add project content #20

Add project content

Add project content #20

Workflow file for this run

name: Dynamic Matrix from config.yaml
on:
push:
branches:
- main
jobs:
test-versions:
name: Build & Test Versions
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup Golang
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.0
with:
go-version: '1.20.5'
- name: Download all Go modules
run: go mod download && go mod tidy
- name: Compile all packages and test versions
run: go run main.go test
prepare-versions:
name: Prepare Versions
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
- name: Get versions from config.yaml
id: get_versions
run: echo "versions=[$(yq -j eval '.versions[].version' config.yaml | tr '\n' ', ' | sed 's/,$/\n/')]" >> $GITHUB_OUTPUT
- name: Print matrix
run: echo "${{ steps.get_versions.outputs.versions }}"
outputs:
versions: ${{ steps.get_versions.outputs.versions }}
build:
name: Build Version
needs:
- test-versions
- prepare-versions
runs-on: ubuntu-20.04
strategy:
max-parallel: 1
matrix:
version: ${{ fromJson(needs.prepare-versions.outputs.versions) }}
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
- name: Edit mocked version
run: yq eval -i ".mockedVersion = \"${{ matrix.version }}\"" "config.yaml"
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
evryn/version-forge
ghcr.io/evryn/version-forge
quay.io/evryn/version-forge
flavor: |
latest=false
tags: |
type=semver,pattern={{version}},value=${{ matrix.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ matrix.version }}
type=semver,pattern={{major}},value=${{ matrix.version }}
labels: |
org.opencontainers.image.vendor=Evryn
org.opencontainers.image.authors=Amirreza Nasiri <nasiri.amirreza.96@gmail.com> and contributors
maintainer=Amirreza Nasiri <nasiri.amirreza.96@gmail.com>
org.label-schema.schema-version=1.0
org.label-schema.vcs-url=https://github.com/${{ github.repository }}.git
org.label-schema.docker.cmd=docker run -d -p 8080:8080 version-forge
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}