Skip to content

Add template option

Add template option #3

name: Build and Deploy to Docker Hub
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Get package version
id: package-version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Get changelog
id: changelog
uses: release-flow/keep-a-changelog-action@v2
with:
command: query
version: ${{ steps.package-version.outputs.version }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ vars.DOCKERHUB_NAMESPACE }}/bitbucket-pipe-summarise-tf-plan:${{ steps.package-version.outputs.version }}
${{ vars.DOCKERHUB_NAMESPACE }}/bitbucket-pipe-summarise-tf-plan:latest
- name: Create Github release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package-version.outputs.version }}
release_name: v${{ steps.package-version.outputs.version }}
body: ${{ steps.changelog.outputs.release-notes }}
draft: false
prerelease: false