Skip to content

fix: Fix create issue #87

fix: Fix create issue

fix: Fix create issue #87

Workflow file for this run

name: Deploy to Render
on:
push:
branches:
- fix/github-actions-rollback
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
- name: Install Dependencies
run: yarn install
- name: Copy .env.test to .env
run: cp .env.test .env
- name: Run tests
run: yarn test
- name: Rollback
if: ${{ failure() && github.event_name == 'push' }}
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
MERGE_COMMIT_SHA=$(git log --merges --pretty=format:"%H" -1)
git revert -m 1 --no-edit --message "Revert PR merge" $MERGE_COMMIT_SHA
elif [[ "${{ steps.determine_event.outputs.event }}" == "push" ]]; then
MERGE_COMMIT_SHA=$(git log --pretty=format:"%H" -1)
git revert -n HEAD --no-edit --message "Revert PR merge" $MERGE_COMMIT_SHA
else
echo "Unknown event type"
fi
git push --force
# Create issue
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/issues \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"title": "Automated issue for commit: ${{ github.sha }}",
"body": "This issue was automatically created by the GitHub Action workflow **${{ github.workflow }}**. \n\n The commit hash was: _${{ github.sha }}_."
}' \
--fail
deploy:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
- name: Install Dependencies
run: yarn install
- name: Build
run: yarn build
- name: Deploy to Render
uses: johnbeynon/render-deploy-action@v0.0.8
with:
service-id: ${{ secrets.SERVICE_ID_DEVELOP }} # Can be found as part of the Deploy Hook
api-key: ${{ secrets.RENDER_API_KEY }} # Create your API key in Render Dashboard > Account Settings
- name: Rollback
if: ${{ failure() && github.event_name == 'push' }}
run: |
git checkout ${{ github.sha }}^1
git push --force
# Post a comment on the pull request
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{"body": "The CI job has failed. The last commit has been rolled back."}' \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${{ github.event.pull_request.number }}/comments"