Skip to content

Commit

Permalink
Add CI to ETOS API and SSE
Browse files Browse the repository at this point in the history
  • Loading branch information
t-persson committed Nov 27, 2023
1 parent 8f9c620 commit 4c529ee
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build and push

on:
pull_request_target:
branches: [ "main" ]
types:
- closed
workflow_dispatch:

jobs:
build_api:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build app image
run: docker build . --tag image

- name: Log into registry
run: echo "${{ secrets.REGISTRYPASSWORD }}" | docker login registry.nordix.org -u ${{ secrets.REGISTRYUSERNAME }} --password-stdin

- name: Push app image
id: image
run: |
IMAGE_ID=registry.nordix.org/eiffel/etos-api
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo $IMAGE_ID:$VERSION
echo "::set-output name=version::$VERSION"
- name: Update manifests
uses: fjogeleit/yaml-update-action@main
with:
valueFile: 'manifests/base/deployment.yaml'
propertyPath: 'spec.template.spec.containers[0].image'
value: registry.nordix.org/eiffel/etos-api:${{ steps.image.outputs.version }}
branch: main
commitChange: true
message: Updating API manifest image to version ${{ steps.image.outputs.version }}
build_sse:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build app image
run: docker build . -f deploy/etos-sse/Dockerfile --tag image

- name: Log into registry
run: echo "${{ secrets.REGISTRYPASSWORD }}" | docker login registry.nordix.org -u ${{ secrets.REGISTRYUSERNAME }} --password-stdin

- name: Push app image
id: image
run: |
IMAGE_ID=registry.nordix.org/eiffel/etos-sse
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo $IMAGE_ID:$VERSION
echo "::set-output name=version::$VERSION"
- name: Update manifests
uses: fjogeleit/yaml-update-action@main
with:
valueFile: 'manifests/base/sse/deployment.yaml'
propertyPath: 'spec.template.spec.containers[0].image'
value: registry.nordix.org/eiffel/etos-sse:${{ steps.image.outputs.version }}
branch: main
commitChange: true
message: Updating SSE manifest image to version ${{ steps.image.outputs.version }}
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
uses: hadolint/hadolint-action@master
with:
dockerfile: Dockerfile
- name: Run hadolint for SSE
uses: hadolint/hadolint-action@master
with:
dockerfile: deploy/etos-sse/Dockerfile

build-docker-images:
# The type of runner that the job will run on
Expand All @@ -57,3 +61,8 @@ jobs:
with:
context: .
file: ./Dockerfile
- name: Build SSE image
uses: docker/build-push-action@v2
with:
context: .
file: ./deploy/etos-sse/Dockerfile

0 comments on commit 4c529ee

Please sign in to comment.