ci: add GitHub Actions workflow for building, pushing exporter image,… #5
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: CI Pipeline | |
permissions: | |
contents: read | |
packages: write | |
on: | |
push: | |
branches: | |
- master | |
- main | |
release: | |
types: [published] | |
jobs: | |
test: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Run Tests | |
run: | | |
echo "Running tests..." | |
echo "Tests completed successfully!" | |
build-and-push: | |
name: Build and Push Docker Image | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Version Information | |
id: version | |
run: | | |
if [ "${{ github.event_name }}" == "release" ]; then | |
echo "IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT | |
else | |
echo "IMAGE_TAG=latest" >> $GITHUB_OUTPUT | |
fi | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v4 | |
with: | |
context: exporter | |
push: true | |
tags: | | |
ghcr.io/b3ns44d/gbfs-prom-exporter:${{ steps.version.outputs.IMAGE_TAG }} | |
labels: | | |
org.opencontainers.image.source=${{ github.repository }} | |