|
| 1 | +# NOTE: This name appears in GitHub's Checks API and in workflow's status badge. |
| 2 | +name: rofl-dev-image |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + # XXX: ideally on main branches we would build the image only if there are changes in the |
| 7 | + # 'docker/' directory (as we do in pull_requests). However, this doesn't work when pushing a new |
| 8 | + # 'stable/*' branch - the build on a new branch does not trigger unless there are changes |
| 9 | + # compared to main on the filtered path. |
| 10 | + # If this is ever fixed, or per branch filters are possible, bring back the path filter to only |
| 11 | + # build the image when there are changes within 'docker/' directory. |
| 12 | + branches: |
| 13 | + - main |
| 14 | + - stable/* |
| 15 | + # Or when a pull request event occurs for a pull request against one of the matched branches and at least |
| 16 | + # one modified file matches the configured paths. |
| 17 | + # |
| 18 | + # NOTE: We use this to be able to easily test Docker image changes. |
| 19 | + pull_request: |
| 20 | + branches: |
| 21 | + - main |
| 22 | + - stable/* |
| 23 | + paths: |
| 24 | + - docker/rofl-dev/** |
| 25 | + # Or every day at 04:00 UTC (for the default/main branch). |
| 26 | + schedule: |
| 27 | + - cron: "0 4 * * *" |
| 28 | + |
| 29 | +# Cancel in-progress jobs on same branch. |
| 30 | +concurrency: |
| 31 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 32 | + cancel-in-progress: true |
| 33 | + |
| 34 | +jobs: |
| 35 | + |
| 36 | + build-rofl-dev: |
| 37 | + # NOTE: This name appears in GitHub's Checks API. |
| 38 | + name: build-rofl-dev |
| 39 | + runs-on: ubuntu-latest |
| 40 | + steps: |
| 41 | + - name: Checkout code |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + # Check out pull request's HEAD commit instead of the merge commit. |
| 45 | + ref: ${{ github.event.pull_request.head.sha }} |
| 46 | + |
| 47 | + - name: Determine tag name |
| 48 | + id: determine-tag |
| 49 | + uses: ./.github/actions/determine-tag |
| 50 | + |
| 51 | + - name: Set up Docker Buildx |
| 52 | + uses: docker/setup-buildx-action@v3 |
| 53 | + |
| 54 | + - name: Login to ghcr.io |
| 55 | + uses: docker/login-action@v3 |
| 56 | + with: |
| 57 | + registry: ghcr.io |
| 58 | + username: ${{ github.actor }} |
| 59 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - name: "Rebuild oasisprotocol/rofl-dev:${{ steps.determine-tag.outputs.tag }}" |
| 62 | + uses: docker/build-push-action@v5 |
| 63 | + with: |
| 64 | + context: docker/rofl-dev |
| 65 | + file: docker/rofl-dev/Dockerfile |
| 66 | + tags: ghcr.io/oasisprotocol/rofl-dev:${{ steps.determine-tag.outputs.tag }} |
| 67 | + pull: true |
| 68 | + push: true |
| 69 | + labels: | |
| 70 | + org.opencontainers.image.source=${{ github.event.repository.html_url }} |
| 71 | + org.opencontainers.image.created=${{ steps.determine-tag.outputs.created }} |
| 72 | + org.opencontainers.image.revision=${{ github.sha }} |
| 73 | +
|
| 74 | + - name: Prune old ghcr.io/oasisprotocol/rofl-dev images |
| 75 | + |
| 76 | + with: |
| 77 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + organization: oasisprotocol |
| 79 | + container: rofl-dev |
| 80 | + keep-younger-than: 7 # days |
| 81 | + keep-last: 2 |
| 82 | + prune-untagged: true |
| 83 | + prune-tags-regexes: ^pr- |
0 commit comments