Merge pull request #42 from RaaLabs/dockerfile #8
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
name: Release opcua server | |
on: | |
push: | |
branches: | |
- '**' | |
paths: | |
- 'MockServer/**' | |
env: | |
IMAGES: ${{ secrets.RAAEDGE_LOGIN_SERVER }}/opcua-test-server | |
COVERAGE_FOLDER: Coverage | |
jobs: | |
ci: | |
name: 'Release OPCUA server' | |
runs-on: ubuntu-latest | |
env: | |
RELEASE: ${{ github.event_name == 'push' && contains('main,master', github.ref_name) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- uses: mathieudutour/[email protected] | |
name: Calculate next version and create tag on GitHub | |
id: tag | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag_prefix: ${{ inputs.component && format('server/v',inputs.component) || 'server/v' }} | |
fetch_all_tags: true | |
dry_run: ${{ env.RELEASE != 'true' }} | |
release_branches: ${{ inputs.branches }} | |
- name: Build Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
push: false | |
no-cache: true | |
context: . | |
file: 'MockServer/Dockerfile.Server' | |
secrets: | | |
NUGET_GITHUB_PACKAGES_USERNAME=${{ secrets.NUGET_GITHUB_PACKAGES_USERNAME }} | |
NUGET_GITHUB_PACKAGES_TOKEN=${{ secrets.NUGET_GITHUB_PACKAGES_TOKEN }} | |
load: true | |
platforms: linux/amd64 | |
tags: image:local | |
build-args: | | |
BUILD_VERSION=${{ steps.tag.outputs.new_version }} | |
- name: Apply version tag to Docker images | |
id: references | |
run: | | |
echo ${{ github.event_name }} | |
IMAGES=$(tr "," "\n" <<<"${{ env.IMAGES }}" | sed "s/^[[:space:]]*//;s/[[:space:]]*$//") | |
echo -e "Images to tag:\n$IMAGES" | |
REFS=$(sed "s/$/:v${{ steps.tag.outputs.new_version }}/" <<<"$IMAGES" | paste -sd "," -) | |
echo -e "References: $REFS" | |
echo "tags=$REFS" >> $GITHUB_OUTPUT | |
- name: 'ACR login' | |
uses: azure/docker-login@v2 | |
with: | |
login-server: ${{ secrets.RAAEDGE_LOGIN_SERVER }} | |
username: ${{ secrets.RAAEDGE_ACR_USERNAME }} | |
password: ${{ secrets.RAAEDGE_ACR_PASSWORD }} | |
- name: Docker push | |
uses: docker/build-push-action@v6 | |
if: ${{ env.RELEASE == 'true' }} | |
with: | |
push: true | |
context: . | |
file: 'MockServer/Dockerfile.Server' | |
secrets: | | |
NUGET_GITHUB_PACKAGES_USERNAME=${{ secrets.NUGET_GITHUB_PACKAGES_USERNAME }} | |
NUGET_GITHUB_PACKAGES_TOKEN=${{ secrets.NUGET_GITHUB_PACKAGES_TOKEN }} | |
platforms: linux/amd64 | |
tags: ${{ steps.references.outputs.tags }} | |
build-args: | | |
BUILD_VERSION=${{ steps.tag.outputs.new_version }} | |
- name: Docker logout | |
if: always() | |
run: | | |
docker logout ${{ secrets.RAAEDGE_LOGIN_SERVER }} | |
docker logout ${{ secrets.RAAEDGE_LOGIN_SERVER_2 }} | |
- name: Create GitHub Release | |
if: ${{ env.RELEASE == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create ${{ steps.tag.outputs.new_tag }} --target=${{ github.sha }} --title="server/v${{ steps.tag.outputs.new_version }}" --notes="${{ steps.tag.outputs.changelog }}" | |