Skip to content

cmd: compute costs in background #55

cmd: compute costs in background

cmd: compute costs in background #55

Workflow file for this run

name: "Build & Publish"
on: [pull_request, push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10
with:
name: st8ed-oss
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build
run: |
nix build .#package
echo "PACKAGE_PATH=$(readlink -f result)" >>$GITHUB_ENV
nix build .#dockerImage
echo "IMAGE_PATH=$(readlink -f result)" >>$GITHUB_ENV
nix build .#helmChart
echo "CHART_PATH=$(readlink -f result)" >>$GITHUB_ENV
- uses: actions/upload-artifact@v3
with:
name: aws-cost-exporter
path: ${{ env.PACKAGE_PATH }}
- uses: actions/upload-artifact@v3
with:
name: aws-cost-exporter-image
path: ${{ env.IMAGE_PATH }}
- uses: actions/upload-artifact@v3
with:
name: aws-cost-exporter-chart
path: ${{ env.CHART_PATH }}
publish:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write # For GitHub Releases
steps:
- uses: actions/download-artifact@v3
with:
name: aws-cost-exporter
path: ./dist/release
- uses: actions/download-artifact@v3
with:
name: aws-cost-exporter-image
path: ./dist/image
- uses: actions/download-artifact@v3
with:
name: aws-cost-exporter-chart
path: ./dist/chart
- name: Retrieve version
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=$(echo $VERSION | sed -e 's/^v//')
# [ "$VERSION" == "master" ] && VERSION=latest
echo "VERSION=$VERSION" >>$GITHUB_ENV
echo "VERSION=$VERSION"
- name: Package release
run: |
tar cf ./dist/aws-cost-exporter-$VERSION.linux-amd64.tar.gz \
-C ./dist/release .
chart=$(find ./dist/chart -type f | grep -o 'aws-cost-exporter-.*\.tgz')
echo "chart=$chart"
mv -v ./dist/chart/*.tgz ./dist/$chart
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push image
run: |
# --preserve-digests \
skopeo copy \
--digestfile /dev/stdout \
dir:./dist/image \
docker://index.docker.io/st8ed/aws-cost-exporter:$VERSION
- name: Create release
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
if: ${{ !endsWith(github.ref, '-rc') }}
with:
name: Release ${{ env.VERSION }}
files: |
./dist/aws-cost-exporter-*.tar.gz
./dist/aws-cost-exporter-chart-*.tgz
fail_on_unmatched_files: true
generate_release_notes: true