0.3.1.rc #20
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: Deploy Production | |
on: | |
release: | |
types: | |
- published | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Docker Buildx | |
id: docker_buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker Build | |
run: | | |
echo ${{ secrets.DOCKER_LOGIN }} | docker login -u ${{ github.actor }} --password-stdin | |
docker buildx create --use | |
docker buildx inspect --bootstrap | |
VERSION=$(node -p "require('./package.json').version") | |
APP=$(node -p "require('./package.json').name") | |
echo "Build: ${APP}.${VERSION}" | |
docker buildx build \ | |
--push \ | |
--platform linux/amd64,linux/arm64/v8 \ | |
--build-arg VERSION=$VERSION \ | |
-t ${{ github.actor }}/${APP}:$VERSION \ | |
-t ${{ github.actor }}/${APP}:latest \ | |
-f .docker/Dockerfile \ | |
. | |
echo "${{ github.actor }}/${APP}:${VERSION}" | |
echo "${{ github.actor }}/${APP}:latest" | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
contents: read | |
deployments: write | |
name: Publish to Cloudflare Pages | |
timeout-minutes: 10 | |
environment: | |
name: production | |
url: ${{ steps.deploy.outputs.deployment-url }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: npm install | |
- name: Build | |
run: | | |
response=$(curl -s -o /dev/null -w "%{http_code}" -X GET "https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/font-generator" \ | |
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}") | |
if [ $response -eq 404 ]; then | |
echo "Project does not exist, creating..." | |
npx wrangler pages project create font-generator --production-branch main | |
else | |
echo "Project exists, skipping creation." | |
fi | |
npm run pages:build | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
- name: Deploy to Cloudflare Pages | |
id: deploy | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
command: pages deploy --branch main |