Skip to content

Commit

Permalink
set-output deprecated (#18)
Browse files Browse the repository at this point in the history
* set-output deprecated

* typo

* env

* Update mx.ini

* typo

* Update build_development.yml

* cleanup

* Update build.yml

* Update build.yml

* Update .github/workflows/build.yml

Co-authored-by: Piero Nicolli <[email protected]>

* Update build_development.yml

---------

Co-authored-by: Piero Nicolli <[email protected]>
  • Loading branch information
mamico and pnicolli authored Dec 11, 2023
1 parent d5bb22c commit 1b9d93a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 31 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]=${{ env.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
10 changes: 4 additions & 6 deletions .github/workflows/build_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,26 @@ 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
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

0 comments on commit 1b9d93a

Please sign in to comment.