Merge pull request #5 from TheMBeat/dependabot/npm_and_yarn/tough-coo… #12
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: Build Docker | |
on: | |
push: | |
branches: [master] | |
tags: | |
- "v*" | |
#Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
deploy: | |
name: Deploy Images | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set environment | |
run: | | |
export TAG="${GITHUB_REF#'refs/tags/'}" | |
echo "GH_TAG=$TAG" >> $GITHUB_ENV | |
echo "COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
echo "COMMIT_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
echo "DOCKER_REPO=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16.x" | |
- name: Node Install | |
run: | | |
npm config set fetch-retry-mintimeout 20000 | |
npm config set fetch-retry-maxtimeout 120000 | |
npm config set fetch-timeout 300000 | |
npm install | |
npm run build | |
- name: Set up QEMU | |
id: qemu | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: all | |
- name: Available platforms | |
run: echo ${{ steps.qemu.outputs.platforms }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Dev Release | |
if: startsWith(github.ref, 'refs/heads/') # Just the branches | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
outputs: | | |
type=registry | |
build-args: | | |
SKIP_BUILD="true" | |
platforms: | | |
linux/amd64 | |
linux/arm/v7 | |
linux/arm64 | |
tags: | | |
${{ env.DOCKER_REPO }}:dev | |
${{ env.DOCKER_REPO }}:${{ env.COMMIT }} | |
${{ env.DOCKER_REPO }}:${{ env.COMMIT_SHORT }} | |
# NOTE: the image source label below is required to make an image | |
# publicly accessible in the Github Container Registry. | |
labels: | | |
org.opencontainers.image.source="https://github.com/${{ github.repository }}" | |
org.opencontainers.image.license=ISC | |
- name: Create commit comment | |
uses: peter-evans/commit-comment@v1 | |
if: startsWith(github.ref, 'refs/heads/') # Just the branches | |
with: | |
body: | | |
**This commit has been published as a Docker image.** 🐋 | |
You can easily try this build out locally with Docker. | |
`docker run -p 3000:3000 ${{ env.DOCKER_REPO }}:${{ env.COMMIT_SHORT }}` | |
# TODO: refactor this to not repeat all the code in the Dev Release step | |
- name: Version Release | |
if: startsWith(github.ref, 'refs/tags/') # Just the tags | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
outputs: | | |
type=registry | |
build-args: | | |
SKIP_BUILD="true" | |
platforms: | | |
linux/amd64 | |
linux/arm/v7 | |
linux/arm64 | |
tags: | | |
${{ env.DOCKER_REPO }}:release | |
${{ env.DOCKER_REPO }}:stable | |
${{ env.DOCKER_REPO }}:latest | |
${{ env.DOCKER_REPO }}:${{ env.GH_TAG }} | |
# NOTE: the image source label below is required to make an image | |
# publicly accessible in the Github Container Registry. | |
labels: | | |
org.opencontainers.image.source="https://github.com/${{ github.repository }}" | |
org.opencontainers.image.license=ISC |