build docker nightly #64
Workflow file for this run
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 nightly | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Some repos have submodules that need to be part of the Docker image | |
with: | |
submodules: recursive | |
- name: Generate a token | |
id: generate-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ vars.NB_BOT_ID }} | |
private-key: ${{ secrets.NB_BOT_KEY }} | |
- name: Set GH_TOKEN | |
run: echo "GH_TOKEN=${{ steps.generate-token.outputs.token }}" >> $GITHUB_ENV | |
- name: Get PR number | |
id: get_pr_number | |
run: | | |
PR_NUMBER=$(gh pr list --state merged --base main --head $GITHUB_SHA --json number --jq .[0].number) | |
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV | |
- name: Check PR labels | |
id: check_labels | |
if: env.PR_NUMBER != '' | |
run: | | |
LABELS=$(gh pr view $PR_NUMBER --json labels --jq '.labels[].name') | |
echo "Labels: $LABELS" | |
if echo "$LABELS" | grep -q 'release'; then | |
echo "::set-output name=should_skip::true" | |
else | |
echo "::set-output name=should_skip::false" | |
fi | |
- name: Skip Workflow if release label is present | |
if: steps.check_labels.outputs.should_skip == 'true' | |
run: | | |
echo "Skipping workflow because PR is labeled with 'release'." | |
exit 0 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Update package.json version | |
run: | | |
SHA=${{ needs.check-pr-label.outputs.sha }} | |
jq ".version = \"build:${SHA}\"" package.json > tmp.$$.json && mv tmp.$$.json package.json | |
cat package.json | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKERHUB_REPO }}:nightly |