Merge pull request #657 from oasisprotocol/ptrus/feature/builder-arte… #18
This file contains hidden or 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: docker-rofl-container-builder | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - docker/rofl-container-builder/** | |
| - .github/workflows/docker-rofl-container-builder.yml | |
| tags: | |
| - 'rofl-container-builder/v[0-9]+.[0-9]+*' | |
| pull_request: | |
| paths: | |
| - docker/rofl-container-builder/** | |
| - .github/workflows/docker-rofl-container-builder.yml | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-rofl-container-builder: | |
| name: build-rofl-container-builder | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Determine tag name | |
| id: determine-tag | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| echo "tag=pr-${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT" | |
| elif [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| # Trim rofl-container-builder/v prefix from tag | |
| TAG="${{ github.ref_name }}" | |
| TAG="${TAG#rofl-container-builder/v}" | |
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "tag=latest" >> "$GITHUB_OUTPUT" | |
| fi | |
| echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to ghcr.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: "Build and push oasisprotocol/rofl-container-builder:${{ steps.determine-tag.outputs.tag }}" | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: docker/rofl-container-builder | |
| file: docker/rofl-container-builder/Dockerfile | |
| tags: ghcr.io/oasisprotocol/rofl-container-builder:${{ steps.determine-tag.outputs.tag }} | |
| pull: true | |
| push: true | |
| labels: | | |
| org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
| org.opencontainers.image.created=${{ steps.determine-tag.outputs.created }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| prune-old-images: | |
| name: prune-old-images | |
| if: ${{ always() }} | |
| needs: [build-rofl-container-builder] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Prune old ghcr.io/oasisprotocol/rofl-container-builder images | |
| uses: vlaurin/[email protected] | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| organization: oasisprotocol | |
| container: rofl-container-builder | |
| keep-younger-than: 7 | |
| keep-last: 2 | |
| prune-tags-regexes: ^pr- |