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

Rework CI workflow names #306

Merged
merged 1 commit into from
Jun 6, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/ci-conversion-webhook.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: conversion-webhook CI
name: "[DOCKER] conversion-webhook"

on:
push:
Expand All @@ -23,12 +23,12 @@ on:
- published

jobs:
call-reusable-docker-workflow:
run:
uses: ./.github/workflows/reusable-docker.yml
with:
docker_org: theiacloud
docker_image: theia-cloud-conversion-webhook
docker_file: dockerfiles/conversion-webhook/Dockerfile
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/ci-landing-page.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Landing Page CI
name: "[DOCKER] landing-page"

on:
push:
Expand All @@ -23,7 +23,7 @@ on:
- published

jobs:
call-reusable-docker-workflow:
run:
uses: ./.github/workflows/reusable-docker.yml
with:
docker_org: theiacloud
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-maven-common.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Maven org.eclipse.theia.cloud.common CI
name: "[MAVEN] common"

on:
push:
Expand All @@ -16,7 +16,7 @@ on:
- published

jobs:
call-reusable-maven-workflow:
run:
permissions:
packages: write
uses: ./.github/workflows/reusable-maven.yml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-maven-conf.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Maven config CI
name: "[MAVEN] maven-conf"

on:
push:
Expand All @@ -16,7 +16,7 @@ on:
- published

jobs:
call-reusable-maven-workflow:
run:
permissions:
packages: write
uses: ./.github/workflows/reusable-maven.yml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-maven-operator.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Maven org.eclipse.theia.cloud.operator CI
name: "[MAVEN] operator"

on:
push:
Expand All @@ -18,7 +18,7 @@ on:
- published

jobs:
call-reusable-maven-workflow:
run:
permissions:
packages: write
uses: ./.github/workflows/reusable-maven.yml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-maven-service.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Maven org.eclipse.theia.cloud.service CI
name: "[MAVEN] service"
on:
push:
branches:
Expand All @@ -17,7 +17,7 @@ on:
- published

jobs:
call-reusable-maven-workflow:
run:
permissions:
packages: write
uses: ./.github/workflows/reusable-maven.yml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-monitor-theia.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Monitor Theia extension CI
name: "[NPM] monitor-theia"

on:
push:
Expand All @@ -19,7 +19,7 @@ on:
- published

jobs:
call-reusable-npm-workflow:
run:
uses: ./.github/workflows/reusable-npm.yml
with:
package_workspace: monitor-theia
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-node-common.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Common node package CI
name: "[NPM] common"

on:
push:
Expand All @@ -19,7 +19,7 @@ on:
- published

jobs:
call-reusable-npm-workflow:
run:
uses: ./.github/workflows/reusable-npm.yml
with:
package_workspace: common
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-operator.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Operator CI
name: "[DOCKER] operator"

on:
push:
Expand All @@ -23,7 +23,7 @@ on:
- published

jobs:
call-reusable-docker-workflow:
run:
uses: ./.github/workflows/reusable-docker.yml
with:
docker_org: theiacloud
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-service.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Service CI
name: "[DOCKER] service"

on:
push:
Expand All @@ -23,7 +23,7 @@ on:
- published

jobs:
call-reusable-docker-workflow:
run:
uses: ./.github/workflows/reusable-docker.yml
with:
docker_org: theiacloud
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-wondershaper.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Wondershaper CI
name: "[DOCKER] wondershaper"

on:
push:
Expand All @@ -19,7 +19,7 @@ on:
- published

jobs:
call-reusable-docker-workflow:
run:
uses: ./.github/workflows/reusable-docker.yml
with:
docker_org: theiacloud
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-demos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Demos CI
name: "[DOCKER] demos"

on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-demo.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reusable workflow publishing demo applications
name: Reusable workflow for demo applications

on:
workflow_call:
Expand Down
77 changes: 31 additions & 46 deletions .github/workflows/reusable-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,80 +39,65 @@ jobs:
run: |
docker build -t ${{ steps.get_tags.outputs.version_tag }} -f ${{ inputs.docker_file }} .

check-version:
publish:
runs-on: ubuntu-latest
if: github.event_name == 'push'
outputs:
is_next_version: ${{ steps.version_check.outputs.is_next_version }}
if: github.event_name == 'push' || github.event_name == 'release'
steps:
- id: version_check
- name: Checkout Repository
uses: actions/checkout@v4

# Check if we have a valid *-next version for merges on main
- name: Check version (only for push events)
if: github.event_name == 'push'
id: version_check
run: |
if [[ $VERSION == *"-next" ]]; then
echo "is_next_version=true" >> $GITHUB_OUTPUT
else
echo "is_next_version=false" >> $GITHUB_OUTPUT
fi

publish-next:
runs-on: ubuntu-latest
needs: check-version
if: github.event_name == 'push' && needs.check-version.outputs.is_next_version == 'true'

steps:
- name: Checkout Repository
uses: actions/checkout@v4

# Create tags according to the state to be published:
# - next version on main merge: create `*-next` and `*-next.<git_sha>` tags
# - release version: create version, `*-next` and `latest` tags
- name: Create docker tags
id: get_tags
if: github.event_name == 'push' && steps.version_check.outputs.is_next_version == 'true' || github.event_name == 'release'
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
if [[ $GITHUB_EVENT_NAME == 'push' ]]; then
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
else
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 "latest_tag=${{ inputs.docker_org }}/${{ inputs.docker_image }}:latest" >> $GITHUB_OUTPUT

# Only build when we will publish, so either a main merge with next-version or a release
- name: Build Docker image
if: github.event_name == 'push' && steps.version_check.outputs.is_next_version == 'true' || github.event_name == 'release'
run: docker build -t ${{ steps.get_tags.outputs.version_tag }} -f ${{ inputs.docker_file }} .

# Only log in to dockerhub when we will publish, so either a main merge with next-version or a release
- name: Login to DockerHub
if: github.event_name == 'push' && steps.version_check.outputs.is_next_version == 'true' || github.event_name == 'release'
uses: docker/login-action@v3
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
# Push for main merges with next version
- name: Push Docker tags (for push events with next version)
if: github.event_name == 'push' && steps.version_check.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.sha_tag }}
docker push ${{ steps.get_tags.outputs.sha_tag }}

publish-latest:
runs-on: ubuntu-latest
if: github.event_name == 'release'

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Create docker tags
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 "latest_tag=${{ inputs.docker_org }}/${{ inputs.docker_image }}:latest" >> $GITHUB_OUTPUT

- name: Build Docker image
run: docker build -t ${{ steps.get_tags.outputs.version_tag }} -f ${{ inputs.docker_file }} .

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

# Push version, next and latest tag for releases (version should be valid semver)
- name: Push version and latest tag
# Push for releases
- name: Push Docker tags (for release events)
if: github.event_name == 'release'
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 tag ${{ steps.get_tags.outputs.version_tag }} ${{ steps.get_tags.outputs.next_tag }}
docker push ${{ steps.get_tags.outputs.next_tag }}
29 changes: 15 additions & 14 deletions .github/workflows/reusable-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ jobs:
cd ${{ inputs.path_to_package }}
mvn verify -fae --no-transfer-progress

check-version:
publish:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'release'
outputs:
is_snapshot_version: ${{ steps.version_check.outputs.is_snapshot_version }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- id: version_check
run: |
cd ${{ inputs.path_to_package }}
Expand All @@ -62,25 +61,24 @@ jobs:
echo "is_snapshot_version=true" >> $GITHUB_OUTPUT
else
echo "is_snapshot_version=false" >> $GITHUB_OUTPUT
fi

publish:
runs-on: ubuntu-latest
needs: check-version
if: (github.event_name == 'push' && needs.check-version.outputs.is_snapshot_version == 'true') || (github.event_name == 'release' && needs.check-version.outputs.is_snapshot_version == 'false')

steps:
- name: Checkout Repository
uses: actions/checkout@v4

# Only continue from here when the version matches the event, so either:
# - main merge with snapshot version
# - release with proper version
- name: Set up JDK 17
if: |
(github.event_name == 'push' && steps.version_check.outputs.is_snapshot_version == 'true') ||
(github.event_name == 'release' && steps.version_check.outputs.is_snapshot_version == 'false')
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"

- name: Build dependencies
if: ${{ inputs.dependencies != '' }}
if: |
${{ inputs.dependencies != '' }} &&
(github.event_name == 'push' && steps.version_check.outputs.is_snapshot_version == 'true') ||
(github.event_name == 'release' && steps.version_check.outputs.is_snapshot_version == 'false')
run: |
IFS=',' read -r -a dirs <<< "${{ inputs.dependencies }}"
for dir in "${dirs[@]}"
Expand All @@ -91,6 +89,9 @@ jobs:
done

- name: Publish package
if: |
(github.event_name == 'push' && steps.version_check.outputs.is_snapshot_version == 'true') ||
(github.event_name == 'release' && steps.version_check.outputs.is_snapshot_version == 'false')
run: |
cd ${{ inputs.path_to_package }}
mvn --batch-mode deploy
Expand Down
Loading