Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
addons-robot authored and KevinMind committed Mar 14, 2024
1 parent 52fbd30 commit b3c34a6
Show file tree
Hide file tree
Showing 17 changed files with 3,058 additions and 87 deletions.
26 changes: 0 additions & 26 deletions .circleci/config.yml

This file was deleted.

68 changes: 68 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: 'Docker Build'
description: 'Builds docker image'
inputs:
push:
required: false
description: "Build and push image to registry (cannot be used together with load)"
default: "false"

outputs:
tags:
description: "The Docker tags for the image"
value: ${{ steps.meta.outputs.tags }}

runs:
using: "composite"
steps:
- name: Validate inputs
shell: bash
run: |
if [[ "${{ inputs.push }}" == "true" && "${{ github.ref }}" == "refs/heads/master" ]]; then
echo "Cannot push to registry from master branch unless we migrate our master build job to GHA."
exit 1
fi
# Setup docker to build for multiple architectures
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
buildkitd-flags: --debug

# Login to a registry to push the image
- name: Login to Container Registry
# Only login if we are pushing the image
if: ${{ inputs.push == 'true' }}
uses: docker/login-action@v3
with:
registry: 'ghcr.io'

# Determine the tags for the image
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# Hard coding our dockerhub imnage name
images: mozilla/test-github-features
tags: |
type=schedule
type=ref,event=tag
type=ref,event=branch
type=ref,event=pr
# set latest tag for default branch
# Disabled for now as we do not use this action for
# The production build
# type=raw,value=latest,enable={{is_default_branch}}
- name: Build Image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
pull: true
push: ${{ inputs.push }}
load: ${{ inputs.push == 'false' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
47 changes: 47 additions & 0 deletions .github/actions/run/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Docker Run Action'
description: 'Run a command in a new container'
inputs:
image:
description: "The Docker image to run"
required: true
options:
description: 'Options'
required: false
run:
description: 'Run command in container'
required: true
runs:
using: 'composite'
steps:
- name: Run Docker Container
shell: bash
run: |
cat <<EOF > exec.sh
#!/bin/bash
whoami
${{ inputs.run }}
EOF
cat <<EOF > root.sh
#!/bin/bash
whoami
su -s /bin/bash -c './exec.sh' olympia
EOF
# Make both files executable
chmod +x exec.sh
chmod +x root.sh
# Debug info
echo "############"
cat root.sh
echo "############"
echo "############"
cat exec.sh
echo "############"
# Execute inside docker container
cat root.sh | docker run ${{ inputs.options }} \
-i --rm -u 0 \
-v $(pwd):/app \
${{ inputs.image }} bash
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Build

on:
create:
workflow_dispatch:

jobs:
ci_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
uses: ./.github/actions/build

19 changes: 0 additions & 19 deletions .github/workflows/ci.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Merge
on:
pull_request:
merge_group:
jobs:
merge_build:
if: ${{ github.event_name == 'merge_group' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build
- name: Update txt
shell: bash
run: |
RANDOM_NUMBER=$((RANDOM % 1000000))
echo "Hello World $RANDOM_NUMBER" > hello.txt
git add hello.txt
git commit -m "Update hello.txt"
git push
21 changes: 0 additions & 21 deletions .github/workflows/merge_queue.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Push

on:
push:
branches:
- master

jobs:
deploy_staging:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Deploy to staging
run: |
echo "Deploying to staging"
# Your deployment script here
deploy_production:
runs-on: ubuntu-latest
needs: deploy_staging
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Deploy to production
run: |
echo "Deploying to production"
# Your deployment script here
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build
- name: Test
uses: ./.github/actions/run
with:
run: |
echo "Testing"
npm run test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build
- name: Lint
uses: ./.github/actions/run
with:
run: |
echo "Linting"
npm run lint
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:18 as base

WORKDIR /app
COPY --chown=node package*.json /app/

RUN /bin/bash <<EOF
npm install
EOF

FROM base as builder

COPY --from=base /app/node_modules /app/node_modules
COPY src package.json tsconfig.json /app/

RUN npm run build

FROM base as final

COPY --from=builder /app/dist /app/dist
COPY --from=base /app/package.json /app/package.json

RUN npm i --omit=dev --no-save

EXPOSE 3000

CMD ["npm", "run", "start"]

18 changes: 0 additions & 18 deletions build.mjs

This file was deleted.

Loading

0 comments on commit b3c34a6

Please sign in to comment.