Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test gh action #1

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
on:
workflow_call:
inputs:
push:
description: Should the images be pushed
default: false
required: false
type: boolean
version:
description: The version used when tagging the image
default: dev
required: false
type: string

jobs:
build_and_push_images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

env:
RELEASE_VERSION: "${{ github.event.release.tag_name }}"
DOCKERHUB_REPO: "otel/demo"
GHCR_REPO: "ghcr.io/open-telemetry/demo"

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get changed files
uses: tj-actions/changed-files@v37

- name: Create list of modified services
run: |
modified_services = []
for file in $(echo "${{ steps.changed_files.outputs.all_changed_files }}" | tr '\n' ' '):
if [[ $file =~ Dockerfile ]]; then
service_name=$(echo $file | awk -F '/' '{print $2}')
modified_services+=($service_name)
fi
echo "Modified services: ${modified_services}"

- name: Create list of services to build
run: |
services_to_build = []
for service_name in "${modified_services[@]}"; do
service_dir=$(echo $service_name | sed 's/\./\//g')
if [[ $(git diff --name-only $service_dir) ]]; then
services_to_build+=($service_name)
fi
done
echo "Services to build: ${services_to_build}"

- name: Update matrix
run: |
matrix.file_tag=()
for service_name in "${services_to_build[@]}"; do
matrix.file_tag+=(
file: ./src/$service_name/Dockerfile
tag_suffix: $service_name
context: ./
)
done
echo "Updated matrix:"
echo "${matrix.file_tag}"

- name: Matrix Build and push demo images
uses: docker/[email protected]
with:
context: ${{ matrix.file_tag.context }}
file: ${{ matrix.file_tag.file }}
platforms: linux/amd64,linux/arm64
push: ${{ inputs.push }}
tags: |
${{ env.DOCKERHUB_REPO }}:${{ inputs.version }}-${{matrix.file_tag.tag_suffix }}
${{ env.GHCR_REPO }}:${{ inputs.version }}-${{ matrix.file_tag.tag_suffix }}
cache-from: type=gha
cache-to: type=gha
78 changes: 8 additions & 70 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,14 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
name: Checks
name: "Build and Publish"

on:
pull_request:
branches: [ main ]
release:
types: [published]

jobs:
markdownlint:
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v3

- name: install dependencies
run: npm install

- name: run markdownlint
run: make markdownlint

yamllint:
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: install yamllint
run: make install-yamllint

- name: run yamllint
run: yamllint . -f github

misspell:
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v3

- name: run misspell
run: make misspell

markdownlinkcheck:
name: markdownlinkcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run link check
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'no'
use-verbose-mode: 'yes'
config-file: '.github/.mlc_config.json'

sanity:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: run sanitycheck.py
run: python3 ./internal/tools/sanitycheck.py

checklicense:
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v3
- name: install tools
run: make install-tools
- name: run checklicense
run: make checklicense
build_and_push_images:
uses: ./.github/workflows/build-images.yml
with:
push: true
version: ${{ github.event.release.tag_name }}"
117 changes: 4 additions & 113 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,116 +8,7 @@ on:

jobs:
build_and_push_images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

env:
RELEASE_VERSION: "${{ github.event.release.tag_name }}"
DOCKERHUB_REPO: "otel/demo"
GHCR_REPO: "ghcr.io/open-telemetry/demo"

strategy:
matrix:
file_tag:
- file: ./src/adservice/Dockerfile
tag_suffix: adservice
context: ./
- file: ./src/cartservice/src/Dockerfile
tag_suffix: cartservice
context: ./
- file: ./src/checkoutservice/Dockerfile
tag_suffix: checkoutservice
context: ./
- file: ./src/currencyservice/Dockerfile
tag_suffix: currencyservice
context: ./src/currencyservice
- file: ./src/emailservice/Dockerfile
tag_suffix: emailservice
context: ./src/emailservice
- file: ./src/featureflagservice/Dockerfile
tag_suffix: featureflagservice
context: ./
- file: ./src/frontend/Dockerfile
tag_suffix: frontend
context: ./
- file: ./src/frontendproxy/Dockerfile
tag_suffix: frontendproxy
context: ./
- file: ./src/loadgenerator/Dockerfile
tag_suffix: loadgenerator
context: ./
- file: ./src/paymentservice/Dockerfile
tag_suffix: paymentservice
context: ./
- file: ./src/productcatalogservice/Dockerfile
tag_suffix: productcatalogservice
context: ./
- file: ./src/quoteservice/Dockerfile
tag_suffix: quoteservice
context: ./
- file: ./src/shippingservice/Dockerfile
tag_suffix: shippingservice
context: ./
- file: ./src/recommendationservice/Dockerfile
tag_suffix: recommendationservice
context: ./
- file: ./src/kafka/Dockerfile
tag_suffix: kafka
context: ./
- file: ./src/accountingservice/Dockerfile
tag_suffix: accountingservice
context: ./
- file: ./src/frauddetectionservice/Dockerfile
tag_suffix: frauddetectionservice
context: ./
- file: ./src/frontend/Dockerfile.cypress
tag_suffix: frontend-tests
context: ./
- file: ./test/Dockerfile
tag_suffix: integrationTests
context: ./

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name != 'pull_request'

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: github.event_name != 'pull_request'

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
max-parallelism = 2

- name: Matrix Build and push demo images
uses: docker/[email protected]
with:
context: ${{ matrix.file_tag.context }}
file: ${{ matrix.file_tag.file }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.DOCKERHUB_REPO }}:${{ env.RELEASE_VERSION || 'pr' }}-${{matrix.file_tag.tag_suffix }}
${{ env.GHCR_REPO }}:${{ env.RELEASE_VERSION || 'pr' }}-${{ matrix.file_tag.tag_suffix }}
cache-from: type=gha
cache-to: type=gha
uses: ./.github/workflows/build-images.yml
with:
push: true
version: ${{ github.event.release.tag_name }}"
Loading
Loading