Skip to content

Commit

Permalink
Merge branch 'mamico-patch-1' into plone606
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Nov 28, 2023
2 parents dccc0be + 82e156e commit 5a82702
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 33 deletions.
44 changes: 19 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,31 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Login to Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get the image id
id: get_image_id
run: |
IMAGE_ID=$(echo ghcr.io/${{ github.repository }} | tr '[A-Z]' '[a-z]')
echo ::set-output name=IMAGE_ID::$IMAGE_ID
echo "IMAGE_ID=$IMAGE_ID" >> "$GITHUB_ENV"
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Get the version PR
run: echo "VERSION=${{ github.head_ref }}" >> "$GITHUB_ENV"
if: github.event_name == 'pull_request'

- name: Get the version
id: get_version
run: |
VERSION="${{ steps.extract_branch.outputs.branch }}"
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo ::set-output name=VERSION::$VERSION
run: echo "VERSION=${{ github.ref_name }}" >> "$GITHUB_ENV"
if: github.event_name != 'pull_request'

- name: Build and push container image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.get_image_id.outputs.IMAGE_ID }}:${{ steps.get_version.outputs.VERSION }}
tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }}
platforms: linux/amd64,linux/arm64

- name: Deploy to rancher # io-comune-test
Expand All @@ -72,7 +66,7 @@ jobs:
project-id: ${{ secrets.RANCHER_PROJECT_ID }} # organization
namespace: ${{ secrets.RANCHER_NAMESPACE }}
workload: ${{ secrets.RANCHER_WORKLOAD }}
image: ${{ steps.get_image_id.outputs.IMAGE_ID }}:${{ steps.get_version.outputs.VERSION }}
image: ${{ env.IMAGE_ID }}:${{ env.VERSION }}
slack-hook-url: ${{ secrets.RANCHER_SLACK_HOOK_URL }}

- name: Trigger job
Expand All @@ -81,7 +75,7 @@ jobs:
curl --fail --request POST \
--form token=${{ secrets.TOKEN }} \
--form ref=main \
--form "variables[GITHUB_TAG]=${{ steps.get_version.outputs.VERSION }}" \
--form "variables[GITHUB_TAG]=$VERSION" \
"https://gitlab.com/api/v4/projects/${{ secrets.PROJECT_ID }}/trigger/pipeline"
build-acceptance-image:
Expand All @@ -100,7 +94,7 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Login to Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -110,21 +104,21 @@ jobs:
id: get_image_id
run: |
IMAGE_ID=$(echo ghcr.io/${{ github.repository }}-acceptance | tr '[A-Z]' '[a-z]')
echo ::set-output name=IMAGE_ID::$IMAGE_ID
echo "IMAGE_ID=$IMAGE_ID" >> "$GITHUB_ENV"
- name: Get the version PR
run: echo "VERSION=${{ github.head_ref }}" >> "$GITHUB_ENV"
if: github.event_name == 'pull_request'

- name: Get the version
id: get_version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo ::set-output name=VERSION::$VERSION
run: echo "VERSION=${{ github.ref_name }}" >> "$GITHUB_ENV"
if: github.event_name != 'pull_request'

- name: Build and push container image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.acceptance
push: true
tags: ${{ steps.get_image_id.outputs.IMAGE_ID }}:${{ steps.get_version.outputs.VERSION }}
tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }}
platforms: linux/amd64,linux/arm64
8 changes: 3 additions & 5 deletions .github/workflows/build_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,19 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get the image id
id: get_image_id
run: |
IMAGE_ID=$(echo ghcr.io/${{ github.repository }} | tr '[A-Z]' '[a-z]')
echo ::set-output name=IMAGE_ID::$IMAGE_ID
echo "IMAGE_ID=$IMAGE_ID" >> "$GITHUB_ENV"
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
run: echo "IMAGE_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV"

- name: Build and push container image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.development
push: true
tags: ${{ steps.get_image_id.outputs.IMAGE_ID }}:${{ steps.extract_branch.outputs.branch }}_development
tags: ${{ env.IMAGE_ID}}:${{ env.IMAGE_BRANCH }}_development
platforms: linux/amd64,linux/arm64
6 changes: 3 additions & 3 deletions mx.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ contraints-out = constraints-mxdev.txt
# custom variables
github = https://github.com

[design.plone.contenttypes]
url = ${settings:github}/RedTurtle/design.plone.contenttypes.git
branch = cekk_check_views
# [design.plone.contenttypes]
# url = ${settings:github}/RedTurtle/design.plone.contenttypes.git
# branch = cekk_check_views

0 comments on commit 5a82702

Please sign in to comment.