Skip to content

Commit

Permalink
fix: rework deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
m4dm4rtig4n committed Jan 22, 2024
1 parent d7320d1 commit 186776c
Showing 1 changed file with 130 additions and 0 deletions.
130 changes: 130 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: "[STAGING] Build/Push Image to GAR"

on:
# release:
# types: [published]
workflow_run:
workflows: ["semantic_release"]
types:
- completed

jobs:

information:
runs-on: [self-hosted, decathlon]
steps:
- uses: actions/checkout@v2

- name: Get version
id: information
run: |
version=$(cat src/main.py |grep VERSION| awk '{print $3}' | tr -d '"')
echo "version=${version}" >> "$GITHUB_ENV"
release_type=$(cat src/main.py |grep VERSION| awk '{print $3}' | tr -d '"'| grep rc)
if [ "$release_type" == "" ]; then
# RELEASE
echo "release_type=release" >> "$GITHUB_ENV"
else
# PRERELEASE
echo "release_type=prerelease" >> "$GITHUB_ENV"
fi
outputs:
version: env.version
release_type: env.release_type

#################################################################################################################
# BUILD & PUSH IMAGE
Build-And-Push-Image-To-Gar:
needs: [informations]
name: Build & Deploy in docker.io
runs-on: [ ubuntu-latest ]
steps:
- name: Checkout
uses: actions/checkout@v2

- 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 }}
- 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...'
- name: Switch app/VERSION
run: |
echo "${{ needs.informations.outputs.version }}" > app/VERSION
##################################################################################################################
# VERSION
- name: Build and push ${{ needs.informations.outputs.version }}
uses: docker/build-push-action@v3
with:
build-args: ARCH=arm32v6 ARCH=arm32v7 ARCH=amd64
file: Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
context: .
# platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
push: true
tags: |
m4dm4rtig4n/enedisgateway2mqtt:${{ needs.informations.outputs.version }}
m4dm4rtig4n/myelectricaldata:${{ needs.informations.outputs.version }}
- 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 }}** image version is up to date'
##################################################################################################################
# LATEST-DEV
- name: Build and push
uses: docker/build-push-action@v2
# if: ${{ github.event.release.prerelease }}
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
push: true
tags: |
m4dm4rtig4n/enedisgateway2mqtt:latest-dev
m4dm4rtig4n/myelectricaldata:latest-dev
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
if: ${{ github.event.release.prerelease }}
with:
args: '**MyElectricalData** : **latest-dev** image version is up to date'
# ##################################################################################################################
# # LATEST
- name: Build and push
uses: docker/build-push-action@v2
if: ${{ !github.event.release.prerelease }}
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
push: true
tags: |
m4dm4rtig4n/enedisgateway2mqtt:latest
m4dm4rtig4n/myelectricaldata:latest
- name: Discord notification
if: ${{ !github.event.release.prerelease }}
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**MyElectricalData** : **latest** image version is up to date'
##################################################################################################################
# FINISH
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**MyElectricalData** : New version available **${{ needs.informations.outputs.version }}**'

0 comments on commit 186776c

Please sign in to comment.