Fixed deployment [PATCH] #47
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: After Push | |
on: [ push ] | |
permissions: | |
contents: write | |
packages: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
select_type: | |
if: contains('["onuratakan"]', github.actor) | |
runs-on: ubuntu-latest | |
outputs: | |
release_type: ${{ steps.any_type.outputs.release_type }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: any_type | |
id: any_type | |
run: | | |
commit_msg=$(git log --format=oneline -n 1 $GITHUB_SHA) | |
if [[ $commit_msg == *"[PATCH]" ]]; then | |
echo "release_type=patch" >> "$GITHUB_OUTPUT" | |
elif [[ $commit_msg == *"[MINOR]" ]]; then | |
echo "release_type=minor" >> "$GITHUB_OUTPUT" | |
elif [[ $commit_msg == *"[MAJOR]" ]]; then | |
echo "release_type=major" >> "$GITHUB_OUTPUT" | |
else | |
echo "Commit message does not end with [PATCH], [MINOR], or [MAJOR]" | |
fi | |
check: | |
needs: select_type | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print Type | |
env: | |
release_type: ${{ needs.select_type.outputs.release_type }} | |
run: | |
echo "$release_type" | |
tagext: | |
needs: select_type | |
runs-on: ubuntu-latest | |
if: ${{ (needs.select_type.outputs.release_type == 'patch') || (needs.select_type.outputs.release_type == 'minor') || (needs.select_type.outputs.release_type == 'major')}} | |
steps: | |
- name: Set Up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GH_PAT }} # Will change after public release | |
fetch-depth: 0 | |
- name: Fetching Tags | |
run: git fetch --tags | |
- name: setup git config | |
run: | | |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
- name: Run Version Bump Script | |
env: | |
release_type: ${{ needs.select_type.outputs.release_type }} | |
run: python bump.py $release_type | |
- name: Getting Tag | |
id: tag_extractor | |
run: echo "latest_tag=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT" | |
outputs: | |
tag: ${{ steps.tag_extractor.outputs.latest_tag }} | |
check_2: | |
needs: tagext | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print Tag | |
env: | |
release_type: ${{ needs.tagext.outputs.tag }} | |
run: | |
echo "$release_type" | |
image: | |
needs: tagext | |
runs-on: ubuntu-latest | |
environment: Deploys | |
steps: | |
- name: Set Up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- uses: nschloe/action-cached-lfs-checkout@v1 | |
with: | |
token: ${{ secrets.GH_PAT }} # Will change after public release | |
fetch-depth: 0 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Adding required env vars for caching Docker build | |
uses: actions/github-script@v7 | |
env: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
script: | | |
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL']) | |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN']) | |
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL']) | |
- name: Echo required env vars | |
shell: bash | |
run: | | |
echo "ACTIONS_CACHE_URL: $ACTIONS_CACHE_URL" | |
echo "ACTIONS_RUNTIME_TOKEN: $ACTIONS_RUNTIME_TOKEN" | |
echo "ACTIONS_RUNTIME_URL: $ACTIONS_RUNTIME_URL" | |
- name: Build and Publish Docker Images | |
env: | |
VERSION: ${{ needs.tagext.outputs.tag }} | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin | |
git fetch | |
cd .. | |
docker buildx build --platform linux/amd64,linux/arm64 -f On-Prem/Dockerfile --push -t ghcr.io/upsonic/on-prem:latest \ | |
--cache-to type=gha,mode=max \ | |
--cache-from type=gha . | |
docker buildx build --platform linux/amd64,linux/arm64 -f On-Prem/Dockerfile --push -t ghcr.io/upsonic/on-prem:$VERSION \ | |
--cache-to type=gha,mode=max \ | |
--cache-from type=gha . | |
release: | |
needs: [ image, tagext ] | |
runs-on: ubuntu-latest | |
environment: Release | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: ncipollo/release-action@v1 | |
with: | |
name: Upsonic ${{ steps.tag_extractor.outputs.latest_tag }} | |
generateReleaseNotes: true | |
tag: ${{ needs.tagext.outputs.tag }} | |