Update Cataclysm-DDA Commit in Manifest #4
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
name: Update Cataclysm-DDA Commit in Manifest | |
on: | |
schedule: | |
- cron: '0 */4 * * *' | |
workflow_dispatch: | |
jobs: | |
update-manifest: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout this repository | |
uses: actions/checkout@v2 | |
with: | |
ref: beta | |
- name: Get latest commit and tag from the latest pre-release | |
run: | | |
RELEASE_DATA=$(curl -s https://api.github.com/repos/CleverRaven/Cataclysm-DDA/releases | jq -r '[.[] | select(.prerelease == true)] | .[0]') | |
LATEST_TAG=$(echo "$RELEASE_DATA" | jq -r '.tag_name') | |
echo "Latest tag is $LATEST_TAG" | |
LATEST_COMMIT=$(echo "$RELEASE_DATA" | jq -r '.target_commitish') | |
echo "Latest commit is $LATEST_COMMIT" | |
echo "LATEST_COMMIT=$LATEST_COMMIT" >> $GITHUB_ENV | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV | |
- name: Update manifest with the latest commit | |
run: | | |
sed -i "s/commit: \".*\"/commit: \"$LATEST_COMMIT\"/" org.cataclysmdda.CataclysmDDA.yml | |
- name: Set up Git | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
- name: Create a new branch | |
run: | | |
NEW_BRANCH="update-manifest-$LATEST_TAG" | |
git checkout -b $NEW_BRANCH | |
git add org.cataclysmdda.CataclysmDDA.yml | |
git commit -m "Update manifest with latest Cataclysm-DDA commit $LATEST_COMMIT ($LATEST_TAG)" | |
git push -u origin $NEW_BRANCH | |
- name: Set NEW_BRANCH Environment Variable | |
run: echo "NEW_BRANCH=update-manifest-$LATEST_TAG" >> $GITHUB_ENV | |
- name: Create Pull Request | |
uses: repo-sync/pull-request@v2 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
source_branch: ${{ env.NEW_BRANCH }} | |
destination_branch: beta | |
pr_title: "Update manifest with latest Cataclysm-DDA commit $LATEST_COMMIT ($LATEST_TAG)" | |
pr_body: "Automatically created PR to update manifest with the latest commit." | |