Skip to content

WIP

WIP #10

Workflow file for this run

name: Skyetel
on: push
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: skyetel
outputs:
matrix: ${{ steps.set-deployment-matrix.outputs.matrix }}
matrixLength: ${{ steps.set-deployment-matrix.outputs.matrixLength }}
packageMatrix: ${{ steps.set-deployment-matrix.outputs.packageMatrix }}
release: ${{ steps.set-deployment-matrix.outputs.deploy }}
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
env:
BUNDLE_FROZEN: false
with:
working-directory: skyetel
bundler-cache: true
- name: Run the tests
run: bundle exec rake
- name: Set Deployment Matrix
id: set-deployment-matrix
run: |
branchName=$(echo '${{ github.ref }}' | sed 's,refs/heads/,,g')
matrixSource=$(cat << EOF
[
{
"environment": "staging",
"branch": "test_release_1",
"release": true
},
{
"environment": "production",
"branch": "main",
"release": true
}
]
EOF
)
matrix=$(echo $matrixSource | jq --arg branchName "$branchName" 'map(. | select((.branch==$branchName)) )')
echo "matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT
echo "matrixLength=$(echo $matrix | jq length)" >> $GITHUB_OUTPUT
echo "packageMatrix={\"platform\":[\"amd64\",\"arm64\"],\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT
echo "release=$(echo $matrix | jq '.[0].release')" >> $GITHUB_OUTPUT
build-packages:
name: Build Packages
runs-on: ubuntu-latest
needs:
- build
strategy:
matrix: ${{fromJSON(needs.build.outputs.packageMatrix)}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Packages
run: |
docker buildx build --output type=local,dest=build --platform linux/${{ matrix.platform }} .
release:
name: Release
runs-on: ubuntu-latest
if: needs.build.outputs.release == 'true'
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
release_tag: ${{ steps.release-please.outputs.tag_name }}
needs:
- build
strategy:
matrix: ${{fromJSON(needs.build.outputs.packageMatrix)}}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: googleapis/release-please-action@v4
id: release-please
with:
token: ${{ secrets.SOMLENG_PERSONAL_ACCESS_TOKEN }}
path: skyetel
upload-packages:
name: Upload Packages
runs-on: ubuntu-latest
needs:
- build-packages
- release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/somleng/somleng-skyetel
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=beta,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }}
type=raw,value=${{ needs.release.outputs.release_tag }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
create-sentry-release:
name: Create Sentry Release
runs-on: ubuntu-latest
needs:
- build
- release
- upload-packages
if: ${{ needs.release.outputs.release_created }}
strategy:
matrix: ${{fromJSON(needs.build.outputs.packageMatrix)}}
steps:
- uses: actions/checkout@v4
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: somleng
SENTRY_PROJECT: somleng-skyetel
with:
environment: ${{ matrix.environment }}
version: ${{ needs.release.outputs.release_tag }}