Add a post step to report telemetry (#492) #1227
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
# Workflow for building and publishing this action's container image | |
name: Build and Publish | |
on: | |
push: | |
branches: | |
- main | |
- releases/* | |
pull_request: {} | |
release: | |
types: | |
- published | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
lint-test-check-transpile: | |
name: Lint, format and test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Use Node.js LTS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: yarn | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
node-modules-${{ runner.os }} | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile --non-interactive | |
- name: Format | |
run: yarn format:check | |
- name: Lint | |
run: yarn lint | |
- name: Test | |
run: yarn test | |
- name: Build actions | |
id: build | |
run: yarn build | |
- name: Check JS Transpile | |
id: diff | |
run: | | |
if [ "$(git diff --ignore-space-at-eol --text out/ | wc -l)" -gt "0" ]; then | |
echo "Detected uncommitted changes after build. See status below:" | |
git diff --ignore-space-at-eol --text out/ | |
exit 1 | |
fi | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
concurrency: ${{ github.ref }} | |
needs: lint-test-check-transpile | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Docker metadata | |
id: metadata | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/alwaysmeticulous/report-diffs-action | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: Configure GHCR credentials | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker build | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
cache-from: type=registry,ref=ghcr.io/alwaysmeticulous/report-diffs-action:cache | |
cache-to: type=registry,ref=ghcr.io/alwaysmeticulous/report-diffs-action:cache,mode=max | |
- name: Bump V1 tag | |
if: github.ref == 'refs/heads/releases/v1' | |
run: | | |
git fetch origin releases/v1 --tags | |
git tag --delete v1 | |
git tag v1 origin/releases/v1 | |
git push --tag --force |