|
| 1 | +name: Build usage-stats |
| 2 | +on: |
| 3 | + push: |
| 4 | + # Branches and paths are exclusive |
| 5 | + branches: ["main"] |
| 6 | + paths: |
| 7 | + - services/usage-stats/** |
| 8 | + tags: |
| 9 | + - usage-stats-v[0-9]+.[0-9]+.[0-9]+ # Semver Release (non-prerelease) |
| 10 | + - usage-stats-v[0-9]+.[0-9]+.[0-9]+-** # Semver release (prerelease) |
| 11 | + pull_request: |
| 12 | + branches: [main] |
| 13 | + paths: |
| 14 | + - services/usage-stats/** |
| 15 | +jobs: |
| 16 | + docker: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + submodules: "recursive" |
| 23 | + # Set up python and poetry |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v4 |
| 26 | + with: |
| 27 | + python-version: 3.11 |
| 28 | + - name: Install Poetry |
| 29 | + run: python3 -m pip install poetry==2.1.1 |
| 30 | + - name: Build and stage local packages |
| 31 | + run: scripts/prepare-services |
| 32 | + - name: Get the version from the tag, if it exists |
| 33 | + run: | |
| 34 | + TAG=${{ github.event.release.tag_name }} |
| 35 | + VERSION=$(echo "${TAG}" | sed -E 's/usage-stats-v//') |
| 36 | + echo "VERSION=${VERSION}" >> $GITHUB_ENV |
| 37 | + - name: Docker meta |
| 38 | + id: meta |
| 39 | + uses: docker/metadata-action@v4 |
| 40 | + with: |
| 41 | + images: hub.opensciencegrid.org/macrostrat/usage-stats |
| 42 | + tags: | |
| 43 | + type=ref,event=pr,suffix=-{{date 'YYYYMMDDHHmmss'}} |
| 44 | + type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmmss'}} |
| 45 | + type=semver,pattern={{version}} |
| 46 | + type=raw,value=latest,enable={{is_default_branch}} |
| 47 | + type=raw,value=sha-{{sha}} |
| 48 | + - name: Set up Docker BuildX |
| 49 | + uses: docker/setup-buildx-action@v2 |
| 50 | + - name: Login to OSG DockerHub |
| 51 | + uses: docker/login-action@v2 |
| 52 | + with: |
| 53 | + registry: hub.opensciencegrid.org |
| 54 | + username: ${{ vars.HARBOR_CLI_NAME }} |
| 55 | + password: ${{ secrets.HARBOR_CLI_SECRET }} |
| 56 | + - name: Build and push |
| 57 | + uses: docker/build-push-action@v5 |
| 58 | + with: |
| 59 | + context: services/usage-stats |
| 60 | + push: true |
| 61 | + tags: ${{ steps.meta.outputs.tags }} |
| 62 | + labels: ${{ steps.meta.outputs.labels }} |
| 63 | + cache-from: type=gha |
| 64 | + cache-to: type=gha,mode=max |
0 commit comments