Skip to content

Update main.yml

Update main.yml #23

Workflow file for this run

# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches:
- main
- development
- staging
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Show variable
run: |
echo "Deploying the site: ${{ vars.APP_URL }}"
- name: Increment version from repository's tags
id: semver-tags
uses: SOLIDSoftworks/semver-tags@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag-prefix: 'stg-'
default-version: 'stg-0.0.0'
dry-run: true
- name: Create new tag
run: |
new_tag="stg-${{ steps.semver-tags.outputs.semantic-version }}"
echo "NEW_TAG=$new_tag" >> "$GITHUB_ENV"
git tag $new_tag
git push origin $new_tag
- name: Generate changelog
id: changelog
run: |
prev_tag="${{ steps.semver-tags.outputs.previous-version }}"
if git log --pretty=format:"%h - %s (%an, %ad)" "$prev_tag..HEAD" > changelog.txt 2>/dev/null; then
log=$(cat changelog.txt)
else
log=""
fi
echo "body=$log" >> "$GITHUB_ENV"
- name: Create and publish release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.NEW_TAG }}
release_name: Staging Release ${{ env.NEW_TAG }}
body: |
Changes:
${{ env.body }}
draft: false
prerelease: true
- name: Deploy to ${{ github.ref_name }} environment
run: |
echo "Deploying to ${{ github.ref_name }} environment"
# Your deploy script/commands here