bug: docker tags must include full name #54
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: Node.js CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: npm i --legacy-peer-deps | |
- run: npm run build | |
env: | |
CI: false | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: build | |
- name: Publish to Cloudflare Pages | |
uses: sctg-development/pages-action-without-url@main | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} | |
directory: build # e.g. 'dist' | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get current date | |
id: getdate | |
run: | | |
export CURRENT_DATE=$(date +'%Y.%m.%d-%H%M') | |
export CURRENT_DATE_WITHOUT_DOTS_HIPHENS=$(echo $CURRENT_DATE | sed 's/[-.]//g') | |
echo $CURRENT_DATE > date.txt | |
echo $CURRENT_DATE_WITHOUT_DOTS_HIPHENS > date_without_dots_hiphens.txt | |
echo "::set-output name=getdate::$CURRENT_DATE" | |
- name: Get Current date without dots and hiphen | |
id: getdatewithoutdotsandhiphens | |
run: | | |
export CURRENT_DATE_WITHOUT_DOTS_HIPHENS=$(cat date_without_dots_hiphens.txt) | |
echo "::set-output name=getdatewithoutdotsandhiphens::$CURRENT_DATE_WITHOUT_DOTS_HIPHENS" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.getdate.outputs.getdate }} | |
release_name: Release ${{ steps.getdate.outputs.getdate }} | |
draft: false | |
prerelease: false | |
- name: Compress build directory | |
run: zip -r build.zip build | |
- name: Upload Release Assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload v${{ steps.getdate.outputs.getdate }} build.zip | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ secrets.DOCKER_IMAGE }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
file: Dockerfile | |
context: . | |
platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: ${{ secrets.DOCKER_IMAGE }}:v${{ steps.getdatewithoutdotsandhiphens.outputs.getdatewithoutdotsandhiphens }}, ${{ secrets.DOCKER_IMAGE }}:latest | |
labels: v${{ steps.getdatewithoutdotsandhiphens.outputs.getdatewithoutdotsandhiphens }} |