Skip to content

Release new version #10

Release new version

Release new version #10

Workflow file for this run

name: Release new version
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: write
env:
WORKING_DIRECTORY: bot
defaults:
run:
working-directory: ./bot
jobs:
build:
name: Build and publish image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up NodeJS
uses: actions/setup-node@v3
with:
node-version: 18.17
- name: Install dependencies
run: npm ci
- name: Bump and push version
id: getver
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
npm version minor
echo "version=$(npm pkg get version | tr -d "'\"")" >> $GITHUB_OUTPUT
git add package.json
git commit -m "Bump version"
git pull --rebase --autostash
git push --follow-tags
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ github.repository }}
tags: |
type=semver,pattern={{version}},value=${{ steps.getver.outputs.version }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: ./${{ env.WORKING_DIRECTORY }}
file: ./${{ env.WORKING_DIRECTORY }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.getver.outputs.version }}
release_name: Release ${{ steps.getver.outputs.version }}
body: |
Get the new version:
```
docker pull j6nca/free-game-notifier:${{ steps.getver.outputs.version }}
```
Or view the image repo [here](https://hub.docker.com/r/j6nca/free-game-notifier/tags)
- name: Notify on failure
if: ${{ failure() }}
env:
DISCORD_MESSAGE: "Workflow failed at: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
run: |
curl -H "Content-Type: application/json" \
-d '{"username": "${{ github.repository }}/${{ github.workflow }}", "content": "${{ env.DISCORD_MESSAGE }}"}' \
"${{ secrets.DISCORD_ALERTS_WEBHOOK }}"