Create matching latest upstream release #277
This file contains 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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# GitHub recommends pinning actions to a commit SHA. | |
# To get a newer version, you will need to update the SHA. | |
# You can also reference a tag or branch, but the action may change without warning. | |
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-docker-hub | |
name: Create matching latest upstream release | |
on: | |
schedule: | |
- cron: '45 0 * * *' | |
jobs: | |
build-push-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get remote release tag | |
id: get-remote-release | |
run: | | |
echo "::set-output name=REMOTE_LATEST_RELEASE::$(curl -s https://api.github.com/repos/esphome/esphome/releases/latest | jq -r .tag_name)" | |
echo "::set-output name=REMOTE_LATEST_BODY::$(curl -s https://api.github.com/repos/esphome/esphome/releases/latest | jq -r .body)" | |
- name: Get local release tag | |
id: get-local-release | |
run: echo "::set-output name=LOCAL_LATEST_RELEASE::$(curl -s https://api.github.com/repos/vxav/esphome-avahi/releases/latest | jq -r .tag_name)" | |
- name: Check if tags are different | |
id: check-tags | |
run: echo "::set-output name=TAGS_DIFFERENT::$(test '${{ steps.get-remote-release.outputs.REMOTE_LATEST_RELEASE }}' != '${{ steps.get-local-release.outputs.LOCAL_LATEST_RELEASE }}'; echo $?)" | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Create GitHub release | |
if: steps.check-tags.outputs.TAGS_DIFFERENT == '0' # Only run if tags are different | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: '' # Update with the path to your release artifact | |
tag_name: ${{ steps.get-remote-release.outputs.REMOTE_LATEST_RELEASE }} | |
title: Release ${{ steps.get-remote-release.outputs.REMOTE_LATEST_RELEASE }} | |
body: ${{ steps.get-remote-release.outputs.REMOTE_RELEASE_BODY }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |