Skip to content

Commit

Permalink
Do not build on full release main pushes
Browse files Browse the repository at this point in the history
Introduce step that checks the version so we can use the information in the IF statment of jobs.
Unfortunately ENVs are not available there, hence the workaround.
Queue monitor-vscode after theia-cloud-demo so they can be build together with one run.
Automate the detection of the version for the demo flow.
Now there is no need to specify on how they should be published.

Contributed on behalf of STMicroelectronics
  • Loading branch information
sgraband committed Jan 25, 2024
1 parent 84a474a commit 39f7b7b
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 54 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/publish-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ name: Publish Demos CI
on:
workflow_dispatch:
inputs:
publish_type:
description: "Which build to trigger"
required: true
default: "next"
type: choice
options:
- next
- latest
publish_theia_cloud_demo:
description: "Publish theia-cloud-demo?"
type: boolean
Expand All @@ -26,40 +18,38 @@ on:

jobs:
publish-theia-cloud-demo:
if: ${{ inputs.publish_theia_cloud_demo == true }}
if: inputs.publish_theia_cloud_demo == true
uses: ./.github/workflows/reusable-demo.yml
with:
docker_org: theiacloud
docker_image: theia-cloud-demo
docker_file: demo/dockerfiles/demo-theia-docker/Dockerfile
docker_location: demo/dockerfiles/demo-theia-docker/.
publish_type: ${{ inputs.publish_type }}
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}

publish-theia-cloud-activity-demo-theia:
if: ${{ inputs.publish_theia_cloud_activity_demo_theia == true }}
if: inputs.publish_theia_cloud_activity_demo_theia == true
uses: ./.github/workflows/reusable-demo.yml
with:
docker_org: theiacloud
docker_image: theia-cloud-activity-demo-theia
docker_file: demo/dockerfiles/demo-theia-monitor-theia/Dockerfile
docker_location: .
publish_type: ${{ inputs.publish_type }}
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}

publish-theia-cloud-activity-demo:
if: ${{ inputs.publish_theia_cloud_activity_demo == true }}
if: inputs.publish_theia_cloud_activity_demo == true
needs: publish-theia-cloud-demo
uses: ./.github/workflows/reusable-demo.yml
with:
docker_org: theiacloud
docker_image: theia-cloud-activity-demo
docker_file: demo/dockerfiles/demo-theia-monitor-vscode/Dockerfile
docker_location: demo/dockerfiles/demo-theia-monitor-vscode/.
publish_type: ${{ inputs.publish_type }}
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
61 changes: 24 additions & 37 deletions .github/workflows/reusable-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ on:
docker_location:
required: true
type: string
publish_type:
description: "Publish as latest ('latest') or next ('next')"
required: true
type: string
secrets:
dockerhub_username:
required: true
Expand All @@ -29,40 +25,21 @@ env:
VERSION: 0.10.0-next

jobs:
publish-next:
check-version:
runs-on: ubuntu-latest
if: ${{ inputs.publish_type == 'next' }}

outputs:
is_next_version: ${{ steps.version_check.outputs.is_next_version }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Create docker tags
id: get_tags
run: |
echo "sha_tag=${{ inputs.docker_org }}/${{ inputs.docker_image }}:${{ env.VERSION }}.$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT
echo "version_tag=${{ inputs.docker_org }}/${{ inputs.docker_image }}:${{ env.VERSION }}" >> $GITHUB_OUTPUT
- name: Build Docker image
run: docker build -t ${{ steps.get_tags.outputs.version_tag }} -f ${{ inputs.docker_file }} ${{ inputs.docker_location }}

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.dockerhub_username }}
password: ${{ secrets.dockerhub_token }}

# Push version and SHA tag for main pushes of next versions (This avoids duplicate pushes for release commits on main)
- name: Push version and SHA tag
if: endsWith(env.VERSION, '-next')
- id: version_check
run: |
docker push ${{ steps.get_tags.outputs.version_tag }}
docker tag ${{ steps.get_tags.outputs.version_tag }} ${{ steps.get_tags.outputs.sha_tag }}
docker push ${{ steps.get_tags.outputs.sha_tag }}
if [[ $VERSION == *"-next" ]]; then
echo "::set-output name=is_next_version::true"
else
echo "::set-output name=is_next_version::false"
fi
publish-latest:
publish-next:
runs-on: ubuntu-latest
if: ${{ inputs.publish_type == 'latest' }}

steps:
- name: Checkout Repository
Expand All @@ -72,7 +49,8 @@ jobs:
id: get_tags
run: |
echo "version_tag=${{ inputs.docker_org }}/${{ inputs.docker_image }}:${{ env.VERSION }}" >> $GITHUB_OUTPUT
echo "next_tag=${{ inputs.docker_org }}/${{ inputs.docker_image }}:${{ env.VERSION }}-next" >> $GITHUB_OUTPUT
echo "next_sha_tag=${{ inputs.docker_org }}/${{ inputs.docker_image }}:${{ env.VERSION }}.$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT
echo "next_tag_for_release=${{ inputs.docker_org }}/${{ inputs.docker_image }}:${{ env.VERSION }}-next" >> $GITHUB_OUTPUT
echo "latest_tag=${{ inputs.docker_org }}/${{ inputs.docker_image }}:latest" >> $GITHUB_OUTPUT
- name: Build Docker image
Expand All @@ -84,11 +62,20 @@ jobs:
username: ${{ secrets.dockerhub_username }}
password: ${{ secrets.dockerhub_token }}

# Push version, next and latest tag for releases (version should be valid semver)
# Push version and SHA tag (for next versions)
- name: Push version and SHA tag
if: needs.check-version.outputs.is_next_version == 'true'
run: |
docker push ${{ steps.get_tags.outputs.version_tag }}
docker tag ${{ steps.get_tags.outputs.version_tag }} ${{ steps.get_tags.outputs.next_sha_tag }}
docker push ${{ steps.get_tags.outputs.next_sha_tag }}
# Push version, next and latest tag for releases (for valid semver versions)
- name: Push version and latest tag
if: needs.check-version.outputs.is_next_version == 'false'
run: |
docker push ${{ steps.get_tags.outputs.version_tag }}
docker tag ${{ steps.get_tags.outputs.version_tag }} ${{ steps.get_tags.outputs.latest_tag }}
docker push ${{ steps.get_tags.outputs.latest_tag }}
docker tag ${{ steps.get_tags.outputs.version_tag }} ${{ steps.get_tags.outputs.next_tag }}
docker push ${{ steps.get_tags.outputs.next_tag }}
docker tag ${{ steps.get_tags.outputs.version_tag }} ${{ steps.get_tags.outputs.next_tag_for_release }}
docker push ${{ steps.get_tags.outputs.next_tag_for_release }}
17 changes: 15 additions & 2 deletions .github/workflows/reusable-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,23 @@ jobs:
run: |
docker build -t ${{ steps.get_tags.outputs.version_tag }} -f ${{ inputs.docker_file }} .
check-version:
runs-on: ubuntu-latest
if: github.event_name == 'next'
outputs:
is_next_version: ${{ steps.version_check.outputs.is_next_version }}
steps:
- id: version_check
run: |
if [[ $VERSION == *"-next" ]]; then
echo "::set-output name=is_next_version::true"
else
echo "::set-output name=is_next_version::false"
fi
publish-next:
runs-on: ubuntu-latest
if: github.event_name == 'push'
if: github.event_name == 'next' && needs.check-version.outputs.is_next_version == 'true'

steps:
- name: Checkout Repository
Expand All @@ -64,7 +78,6 @@ jobs:

# Push version and SHA tag for main pushes of next versions (This avoids duplicate pushes for release commits on main)
- name: Push version and SHA tag
if: endsWith(env.VERSION, '-next')
run: |
docker push ${{ steps.get_tags.outputs.version_tag }}
docker tag ${{ steps.get_tags.outputs.version_tag }} ${{ steps.get_tags.outputs.sha_tag }}
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/reusable-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,23 @@ jobs:
- name: Build package
run: npm run build -w ${{ inputs.package_workspace }}

check-version:
runs-on: ubuntu-latest
if: github.event_name == 'next'
outputs:
is_next_version: ${{ steps.version_check.outputs.is_next_version }}
steps:
- id: version_check
run: |
if [[ $VERSION == *"-next" ]]; then
echo "::set-output name=is_next_version::true"
else
echo "::set-output name=is_next_version::false"
fi
publish-next:
runs-on: ubuntu-latest
if: github.event_name == 'push'
if: github.event_name == 'next' && needs.check-version.outputs.is_next_version == 'true'
defaults:
run:
working-directory: ./node
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [0.10.0] - estimated 2024-04

- [.github/workflows] Improve version detection in workflows (do not build release commits, auto-detect version for demo publishing) [#280](https://github.com/eclipsesource/theia-cloud/pull/280) - contributed on behalf of STMicroelectronics

## [0.9.0] - 2024-01-23

- [node/landing-page] Make npm workspace and remove yarn references from repo [#258](https://github.com/eclipsesource/theia-cloud/pull/258) | [#45](https://github.com/eclipsesource/theia-cloud-helm/pull/45) - contributed on behalf of STMicroelectronics
Expand Down

0 comments on commit 39f7b7b

Please sign in to comment.