Merge pull request #4 from flipperdevices/PD-397-dependabot #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Build docker image' | |
on: | |
push: | |
branches: | |
- dev | |
tags: | |
- '*' | |
env: | |
IMAGE_NAME: "flipperdevices/firmware-report-server" | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: 'Checkout code' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: 'Set image tag' | |
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_OUTPUT | |
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
- name: 'Login to Docker Hub' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_REGISTRY_LOGIN }} | |
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | |
- name: 'Set up Docker Buildx' | |
uses: docker/setup-buildx-action@v2 | |
- name: 'Build and push' | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: ${{steps.tag.outputs.image_name}}:${{steps.tag.outputs.image_tag}} | |
cache-from: type=registry,ref=${{ steps.tag.outputs.image_name }}:buildcache | |
cache-to: type=registry,ref=${{ steps.tag.outputs.image_name }}:buildcache,mode=max | |
- name: 'Trigger k8s to use new image' | |
if: ${{ steps.tag.outputs.image_tag != '0.0.0' }} | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
repository: ${{ secrets.INFRASTRUCTURE_REPO }} | |
token: ${{ secrets.K8S_GITHUB_PAT }} | |
event-type: fw-reports-flipp-dev-server-deploy | |
client-payload: '{"image_tag": "${{steps.tag.outputs.image_tag}}"}' |