Docker cleanup #85
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 Pipeline | |
on: | |
workflow_dispatch: | |
push: | |
branches: ["main", "dev"] | |
paths: ["!PostmanCollections/**", "!./github/**"] | |
pull_request: | |
branches: [ "dev" ] | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Cache Node.js dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm- | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install Dependencies | |
run: npm ci | |
- name: Generate OAS 3.0 | |
run: npm run generateoas | |
- name: Start Server | |
run: npm start & npx wait-on http://localhost:3000 | |
- name: Run Tests | |
run: npm test | |
- name: Upload HTML Report | |
uses: actions/[email protected] | |
with: | |
name: html-report | |
path: newman/*.html | |
build_and_push_docker_image: | |
needs: build_and_test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into GitHub Container Registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }} | |
restore-keys: | | |
${{ runner.os }}-docker- | |
- name: Build and Push Docker Image | |
run: | | |
docker buildx create --use | |
docker buildx build --platform linux/amd64 -t ghcr.io/${{ github.repository }}:dev --push . | |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
docker buildx build --platform linux/amd64 -t ghcr.io/${{ github.repository }}:main --push . | |
fi | |
docker buildx stop | |
deploy_to_fly: | |
needs: build_and_push_docker_image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Get FlyCtl | |
uses: superfly/flyctl-actions/setup-flyctl@master | |
- name: Determine File Based on Branch | |
id: determine-env | |
run: | | |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
cp fly.production.toml fly.toml | |
echo "DEPLOY_TARGET=Fly" >> $GITHUB_ENV | |
else | |
cp fly.staging.toml fly.toml | |
echo "DEPLOY_TARGET=FlyDev" >> $GITHUB_ENV | |
fi | |
- name: start deployment | |
uses: bobheadxi/deployments@v1 | |
id: deployment | |
with: | |
step: start | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: ${{ env.DEPLOY_TARGET }} | |
- name: Deploy to Fly | |
run: flyctl deploy | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
- name: update deployment status | |
uses: bobheadxi/deployments@v1 | |
if: always() | |
with: | |
step: finish | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: ${{ job.status }} | |
env: ${{ steps.deployment.outputs.env }} | |
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
- name: Cache FlyCtl binary | |
uses: actions/cache@v3 | |
with: | |
path: ~/.fly | |
key: ${{ runner.os }}-flyctl | |
restore-keys: | | |
${{ runner.os }}-flyctl- |