Skip to content

feature/add_axios (#53) #174

feature/add_axios (#53)

feature/add_axios (#53) #174

Workflow file for this run

name: 'Deploy'
on:
push:
branches:
- main
- dev
tags:
- '*'
env:
IMAGE_NAME: "ghcr.io/flipperdevices/lab.flipper.net"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout code'
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Set image tag and name'
id: tag
run: |
IMAGE_TAG="0.0.0"
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
REF=${{ github.ref }};
TAG_FULL=${REF#refs/*/};
IMAGE_TAG=${TAG_FULL//\//_};
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
- name: 'Login to Docker Hub'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: 'Set up Docker Buildx'
uses: docker/setup-buildx-action@v2
- name: 'Build and push dev'
if: ${{ steps.tag.outputs.image_tag == '0.0.0' }}
id: docker_build_dev
uses: docker/build-push-action@v4
with:
push: true
tags: ${{steps.tag.outputs.image_name}}:${{steps.tag.outputs.image_tag}}
file: Dockerfile-dev
- name: 'Build and push prod'
if: ${{ steps.tag.outputs.image_tag != '0.0.0' }}
id: docker_build_prod
uses: docker/build-push-action@v4
with:
push: true
tags: ${{steps.tag.outputs.image_name}}:${{steps.tag.outputs.image_tag}}
file: Dockerfile-prod
- name: 'Show dev image digest'
if: ${{ steps.tag.outputs.image_tag == '0.0.0' }}
run: |
echo ${{ steps.docker_build_dev.outputs.digest }}
- name: 'Show prod image digest'
if: ${{ steps.tag.outputs.image_tag != '0.0.0' }}
run: |
echo ${{ steps.docker_build_prod.outputs.digest }}
- name: 'Trigger k8s to use new image'
uses: peter-evans/repository-dispatch@v2
with:
repository: ${{ secrets.INFRASTRUCTURE_REPO }}
token: ${{ secrets.K8S_GITHUB_PAT }}
event-type: lab-flipper-net-deploy
client-payload: '{"image_tag": "${{steps.tag.outputs.image_tag}}"}'