Skip to content

Commit

Permalink
Apply github action
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-vasconcelos committed Oct 2, 2024
1 parent 79739be commit cfbbb2f
Showing 1 changed file with 3 additions and 346 deletions.
349 changes: 3 additions & 346 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,113 +3,15 @@ name: Build & Publish Docker Images
on:
push:
branches:
- beta
- production

jobs:
#

# # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #

api-parse-datasets:
name: parse-datasets (NodeJS)
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: read
packages: write

steps:
- name: Set module key
run: |
echo "MODULE_KEY=parse-datasets" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@main

- name: Calculate module SHA256 hash
run: |
find "./${{ env.MODULE_KEY }}" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1 > ${{ env.MODULE_KEY }}.hash
echo "SHA256_HASH=$(cat ${{ env.MODULE_KEY }}.hash)" >> $GITHUB_ENV
- name: Fetch hash cache
uses: actions/cache@v4
id: cache
with:
path: ${{ env.MODULE_KEY }}.hash
key: ${{ github.ref_name }}-${{ env.MODULE_KEY }}-${{ env.SHA256_HASH }}

- name: Login to GitHub Container Registry
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@master
with:
push: true
context: ./${{ env.MODULE_KEY }}
file: ./${{ env.MODULE_KEY }}/Dockerfile
tags: ghcr.io/carrismetropolitana/api-${{ env.MODULE_KEY }}:${{ github.ref_name }}

# # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #

api-parse-network:
name: parse-network (NodeJS)
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: read
packages: write

steps:
- name: Set module key
run: |
echo "MODULE_KEY=parse-network" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@main

- name: Calculate module SHA256 hash
run: |
find "./${{ env.MODULE_KEY }}" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1 > ${{ env.MODULE_KEY }}.hash
echo "SHA256_HASH=$(cat ${{ env.MODULE_KEY }}.hash)" >> $GITHUB_ENV
- name: Fetch hash cache
uses: actions/cache@v4
id: cache
with:
path: ${{ env.MODULE_KEY }}.hash
key: ${{ github.ref_name }}-${{ env.MODULE_KEY }}-${{ env.SHA256_HASH }}

- name: Login to GitHub Container Registry
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@master
with:
push: true
context: ./${{ env.MODULE_KEY }}
file: ./${{ env.MODULE_KEY }}/Dockerfile
tags: ghcr.io/carrismetropolitana/api-${{ env.MODULE_KEY }}:${{ github.ref_name }}

# # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #

api-server:
navegante-proxy-server:
name: server (NodeJS)
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -153,249 +55,4 @@ jobs:
push: true
context: ./${{ env.MODULE_KEY }}
file: ./${{ env.MODULE_KEY }}/Dockerfile
tags: ghcr.io/carrismetropolitana/api-${{ env.MODULE_KEY }}:${{ github.ref_name }}

# # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #

api-switch:
name: switch (NodeJS)
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: read
packages: write

steps:
- name: Set module key
run: |
echo "MODULE_KEY=switch" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@main

- name: Calculate module SHA256 hash
run: |
find "./${{ env.MODULE_KEY }}" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1 > ${{ env.MODULE_KEY }}.hash
echo "SHA256_HASH=$(cat ${{ env.MODULE_KEY }}.hash)" >> $GITHUB_ENV
- name: Fetch hash cache
uses: actions/cache@v4
id: cache
with:
path: ${{ env.MODULE_KEY }}.hash
key: ${{ github.ref_name }}-${{ env.MODULE_KEY }}-${{ env.SHA256_HASH }}

- name: Login to GitHub Container Registry
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@master
with:
push: true
context: ./${{ env.MODULE_KEY }}
file: ./${{ env.MODULE_KEY }}/Dockerfile
tags: ghcr.io/carrismetropolitana/api-${{ env.MODULE_KEY }}:${{ github.ref_name }}

# # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #

api-sync-alerts:
name: sync-alerts (NodeJS)
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: read
packages: write

steps:
- name: Set module key
run: |
echo "MODULE_KEY=sync-alerts" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@main

- name: Calculate module SHA256 hash
run: |
find "./${{ env.MODULE_KEY }}" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1 > ${{ env.MODULE_KEY }}.hash
echo "SHA256_HASH=$(cat ${{ env.MODULE_KEY }}.hash)" >> $GITHUB_ENV
- name: Fetch hash cache
uses: actions/cache@v4
id: cache
with:
path: ${{ env.MODULE_KEY }}.hash
key: ${{ github.ref_name }}-${{ env.MODULE_KEY }}-${{ env.SHA256_HASH }}

- name: Login to GitHub Container Registry
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@master
with:
push: true
context: ./${{ env.MODULE_KEY }}
file: ./${{ env.MODULE_KEY }}/Dockerfile
tags: ghcr.io/carrismetropolitana/api-${{ env.MODULE_KEY }}:${{ github.ref_name }}

# # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #

api-sync-metrics:
name: sync-metrics (NodeJS)
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: read
packages: write

steps:
- name: Set module key
run: |
echo "MODULE_KEY=sync-metrics" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@main

- name: Calculate module SHA256 hash
run: |
find "./${{ env.MODULE_KEY }}" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1 > ${{ env.MODULE_KEY }}.hash
echo "SHA256_HASH=$(cat ${{ env.MODULE_KEY }}.hash)" >> $GITHUB_ENV
- name: Fetch hash cache
uses: actions/cache@v4
id: cache
with:
path: ${{ env.MODULE_KEY }}.hash
key: ${{ github.ref_name }}-${{ env.MODULE_KEY }}-${{ env.SHA256_HASH }}

- name: Login to GitHub Container Registry
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@master
with:
push: true
context: ./${{ env.MODULE_KEY }}
file: ./${{ env.MODULE_KEY }}/Dockerfile
tags: ghcr.io/carrismetropolitana/api-${{ env.MODULE_KEY }}:${{ github.ref_name }}

# # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #

api-sync-stores:
name: sync-stores (NodeJS)
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: read
packages: write

steps:
- name: Set module key
run: |
echo "MODULE_KEY=sync-stores" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@main

- name: Calculate module SHA256 hash
run: |
find "./${{ env.MODULE_KEY }}" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1 > ${{ env.MODULE_KEY }}.hash
echo "SHA256_HASH=$(cat ${{ env.MODULE_KEY }}.hash)" >> $GITHUB_ENV
- name: Fetch hash cache
uses: actions/cache@v4
id: cache
with:
path: ${{ env.MODULE_KEY }}.hash
key: ${{ github.ref_name }}-${{ env.MODULE_KEY }}-${{ env.SHA256_HASH }}

- name: Login to GitHub Container Registry
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@master
with:
push: true
context: ./${{ env.MODULE_KEY }}
file: ./${{ env.MODULE_KEY }}/Dockerfile
tags: ghcr.io/carrismetropolitana/api-${{ env.MODULE_KEY }}:${{ github.ref_name }}

# # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #

api-sync-vehicles:
name: sync-vehicles (NodeJS)
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: read
packages: write

steps:
- name: Set module key
run: |
echo "MODULE_KEY=sync-vehicles" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@main

- name: Calculate module SHA256 hash
run: |
find "./${{ env.MODULE_KEY }}" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1 > ${{ env.MODULE_KEY }}.hash
echo "SHA256_HASH=$(cat ${{ env.MODULE_KEY }}.hash)" >> $GITHUB_ENV
- name: Fetch hash cache
uses: actions/cache@v4
id: cache
with:
path: ${{ env.MODULE_KEY }}.hash
key: ${{ github.ref_name }}-${{ env.MODULE_KEY }}-${{ env.SHA256_HASH }}

- name: Login to GitHub Container Registry
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@master
with:
push: true
context: ./${{ env.MODULE_KEY }}
file: ./${{ env.MODULE_KEY }}/Dockerfile
tags: ghcr.io/carrismetropolitana/api-${{ env.MODULE_KEY }}:${{ github.ref_name }}
tags: ghcr.io/carrismetropolitana/navegante-proxy-${{ env.MODULE_KEY }}:${{ github.ref_name }}

0 comments on commit cfbbb2f

Please sign in to comment.