-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a CI workflow for ETOS suite starter (#25)
This workflow will run when a PR is merged, it will build the docker image with the current SHA as tag and push it to the registry. After the image has been pushed it will update the image version in the manifests and push them to main.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Build and push | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
types: | ||
- closed | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
if: 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/${{ github.repository }} | ||
# 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-suite-starter:${{ steps.image.outputs.version }} | ||
commitChange: true | ||
message: Updating manifest image to version ${{ steps.image.outputs.version }} |