Skip to content

Instantly share code, notes, and snippets.

@schmichri
Last active March 14, 2025 07:10
Show Gist options
  • Select an option

  • Save schmichri/2c7b12edb62845249de601c0c3c46f7f to your computer and use it in GitHub Desktop.

Select an option

Save schmichri/2c7b12edb62845249de601c0c3c46f7f to your computer and use it in GitHub Desktop.
Build Angular Site with Docker. Extracts version from package.json and injects it in the Dockerfile https://www.license-token.com/
name: Build and Push Docker Image
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
# fetch-depth here to ensure the timestamps are readable
fetch-depth: 0
- name: Extract version from package.json
id: extract_version
run: |
IMAGE_TAG=$(node -p "require('./package.json').version")
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
echo "Version to be used as tag: $IMAGE_TAG"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Private Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build the Docker image
run: |
docker build -t license-token-website:$IMAGE_TAG .
docker push license-token-website:$IMAGE_TAG
- name: Inspect
run: |
docker image inspect license-token-website:$IMAGE_TAG
@schmichri
Copy link
Author

@schmichri
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment