Skip to content

Commit

Permalink
fix: use external workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
m4dm4rtig4n committed Jan 24, 2024
1 parent 3bbeacc commit ebe074c
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 161 deletions.
116 changes: 38 additions & 78 deletions .github/workflows/deploy_prerelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
types:
- completed

env:
IMAGE_REPO: m4dm4rtig4n
IMAGE_NAME: myelectricaldata

jobs:

Expand All @@ -14,11 +17,17 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get version
id: informations
run: |
version=$(cat src/__version__.py |grep VERSION| awk '{print $3}' | tr -d '"')
echo "version=v${version}" >> "$GITHUB_OUTPUT"
version=v$(cat src/__version__.py |grep VERSION| awk '{print $3}' | tr -d '"')
echo "version=${version}" >> "$GITHUB_OUTPUT"
release_type=$(cat src/__version__.py |grep VERSION| awk '{print $3}' | tr -d '"'| grep rc)
if [ "$release_type" == "" ]; then
# RELEASE
Expand All @@ -27,87 +36,38 @@ jobs:
# PRERELEASE
echo "release_type=prerelease" >> "$GITHUB_OUTPUT"
fi
if [ $(docker manifest inspect ${IMAGE_REPO}/${IMAGE_NAME}:${version}) == "" ]; then
echo "build=true" >> "$GITHUB_OUTPUT"
else
echo "build=false" >> "$GITHUB_OUTPUT"
outputs:
version: ${{ steps.informations.outputs.version }}
release_type: ${{ steps.informations.outputs.release_type }}
build: ${{ steps.informations.outputs.build }}

Begin:
needs: [informations]
name: Begin
runs-on: [ ubuntu-latest ]
steps:
- name: Discord notification building state
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**MyElectricalData** : Version **${{ needs.informations.outputs.version }}** is in building state...'
Discord-Begin:
uses: MyElectricalData/.github/actions/discord@main
with:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
MESSAGE: '**MyElectricalData** : Version **${{ needs.informations.outputs.version }}** is in building state...'

#################################################################################################################
# BUILD & PUSH IMAGE
Build-And-Push-Image:
needs: [informations, Begin]
name: Build & Push
runs-on: [ ubuntu-latest ]
steps:
- name: Checkout
uses: actions/checkout@v2
#################################################################################################################
# SETUP DOCKER
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

#################################################################################################################
# VERSION
- name: Build and push ${{ needs.informations.outputs.version }} / latest-dev
uses: docker/build-push-action@v5
with:
file: Dockerfile
platforms: linux/amd64, linux/arm64, linux/arm/v6, linux/arm/v7
context: .
push: true
tags: |
m4dm4rtig4n/enedisgateway2mqtt:${{ needs.informations.outputs.version }}
m4dm4rtig4n/enedisgateway2mqtt:latest-dev
m4dm4rtig4n/myelectricaldata:${{ needs.informations.outputs.version }}
m4dm4rtig4n/myelectricaldata:latest-dev
uses: MyElectricalData/.github/actions/dockerhub-build-push@main
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
IMAGE_REPO: ${IMAGE_REPO}
IMAGE_NAME: ${IMAGE_NAME}
PUSH: true
TAG: ${{ needs.informations.outputs.version }}
PLATFORM: "linux/amd64, linux/arm64, linux/arm/v6, linux/arm/v7"
LATEST: false

##################################################################################################################
# LATEST
- name: Build and push
uses: docker/build-push-action@v5
if: ${{ needs.informations.outputs.release_type == 'release' }}
with:
file: Dockerfile
context: .
platforms: linux/amd64, linux/arm64, linux/arm/v6, linux/arm/v7
push: true
tags: |
m4dm4rtig4n/enedisgateway2mqtt:latest
m4dm4rtig4n/myelectricaldata:latest
- name: Discord notification ${{ needs.informations.outputs.version }} image version is up to date
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**MyElectricalData** : **${{ needs.informations.outputs.version }}/latest** image version is up to date'

Finish:
needs: [informations, Build-And-Push-Image]
name: Finish
runs-on: [ ubuntu-latest ]
steps:
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**MyElectricalData** : New version available **${{ needs.informations.outputs.version }}**'
Discord-Finish:
uses: MyElectricalData/.github/actions/discord@main
with:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
MESSAGE: '**MyElectricalData** : New version available **${{ needs.informations.outputs.version }}**'
101 changes: 42 additions & 59 deletions .github/workflows/deploy_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,78 +7,61 @@ on:
description: "The tag RC version to release."
required: true

env:
IMAGE_REPO: m4dm4rtig4n
IMAGE_NAME: myelectricaldata

jobs:

informations:
runs-on: [ ubuntu-latest ]
steps:

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Generate release version
id: informations
run: |
echo "version=$(${{ github.event.inputs.version }} |awk -F '-' '{print $1}')" >> "$GITHUB_OUTPUT"
version=$(echo "${{ github.event.inputs.version }} |awk -F '-' '{print $1}')"
echo "version=${version}" >> "$GITHUB_OUTPUT"
if [ $(docker manifest inspect ${IMAGE_REPO}/${IMAGE_NAME}:${version}) == "" ]; then
echo "build=true" >> "$GITHUB_OUTPUT"
else
echo "build=false" >> "$GITHUB_OUTPUT"
outputs:
version: ${{ steps.informations.outputs.version }}
build: ${{ steps.informations.outputs.build }}

Begin:
Discord-Begin:
needs: [informations]
name: Begin
runs-on: [ ubuntu-latest ]
steps:
- name: Discord notification building state
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**MyElectricalData** : Version **${{ needs.informations.outputs.version }}** is in building state...'
if: ${{ needs.informations.outputs.build == true }}
uses: MyElectricalData/.github/actions/discord@main
with:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
MESSAGE: '**MyElectricalData** : Version **${{ needs.informations.outputs.version }}** is in building state...'

#################################################################################################################
# BUILD & PUSH IMAGE
Build-And-Push-Image:
needs: [informations, Begin]
name: Build & Push
runs-on: [ ubuntu-latest ]
steps:
- name: Checkout
uses: actions/checkout@v2
#################################################################################################################
# SETUP DOCKER
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
needs: [informations, Discord-Begin]
uses: MyElectricalData/.github/actions/dockerhub-build-push@main
with:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
IMAGE_REPO: ${IMAGE_REPO}
IMAGE_NAME: ${IMAGE_NAME}
PUSH: true
TAG: ${{ needs.informations.outputs.version }}
PLATFORM: "linux/amd64, linux/arm64, linux/arm/v6, linux/arm/v7"
LATEST: true

#################################################################################################################
# VERSION
- name: Build and push ${{ needs.informations.outputs.version }} / latest-dev
uses: docker/build-push-action@v5
with:
file: Dockerfile
platforms: linux/amd64, linux/arm64, linux/arm/v6, linux/arm/v7
context: .
push: true
tags: |
m4dm4rtig4n/enedisgateway2mqtt:${{ needs.informations.outputs.version }}
m4dm4rtig4n/enedisgateway2mqtt:latest-dev
m4dm4rtig4n/myelectricaldata:${{ needs.informations.outputs.version }}
m4dm4rtig4n/myelectricaldata:latest-dev
m4dm4rtig4n/enedisgateway2mqtt:latest
m4dm4rtig4n/myelectricaldata:latest
Finish:
needs: [informations, Build-And-Push-Image]
name: Finish
runs-on: [ ubuntu-latest ]
steps:
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**MyElectricalData** : New version available **${{ needs.informations.outputs.version }}**'
Discord-Finish:
needs: [Build-And-Push-Image]
uses: MyElectricalData/.github/actions/discord@main
with:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
MESSAGE: '**MyElectricalData** : New version available **${{ needs.informations.outputs.version }}**'
13 changes: 13 additions & 0 deletions .github/workflows/semantic_prerelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "semantic_release"

on:
push:
branches:
- main

jobs:

Semantic-Pre-Release:
uses: MyElectricalData/.github/workflows/python_semantic_release.yaml@main
with:
PRE_RELEASE: true
29 changes: 5 additions & 24 deletions .github/workflows/semantic_release.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
name: "semantic_release"
name: "Release in production"

on:
push:
branches:
- main
workflow_dispatch:

jobs:

#################################################################################################################
# SEMANTIC RELEASE
Semantic-Release:
runs-on: ubuntu-latest
concurrency: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

#################################################################################################################
# GENERATE RELEASE
- name: Release
uses: python-semantic-release/python-semantic-release@v8.7.0
with:
directory: ./
github_token: ${{ secrets.GITHUB_TOKEN }}
push: true
uses: MyElectricalData/.github/workflows/python_semantic_release.yaml@main
with:
PRE_RELEASE: false

0 comments on commit ebe074c

Please sign in to comment.