Skip to content

Commit

Permalink
Clear Github Actions Workflow build cache
Browse files Browse the repository at this point in the history
  • Loading branch information
igorsereda committed Jul 28, 2024
1 parent c02c8aa commit 5913b70
Showing 1 changed file with 18 additions and 94 deletions.
112 changes: 18 additions & 94 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,100 +12,24 @@ on:
workflow_dispatch:

jobs:
build:
name: Build and push docker image
cleanup:
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_BASE: ${{ github.repository_owner }}
outputs:
operator: ${{ steps.meta-etherlink.outputs.tags }}
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to the registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Etherlink tags & labels
id: meta-etherlink
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/etherlink

- name: Init cachebust
id: cachebust
run: echo "date=$(date +%s)\n" >> $GITHUB_OUTPUT

- name: Etherlink build & push
uses: docker/build-push-action@v2
with:
context: .
file: build/etherlink/Dockerfile
build-args: |
OCTEZ_TAG=master
OCTEZ_PROTO=PsParisC
PACKAGE=evm_kernel
TEZOS_REPO=https://gitlab.com/tezos/tezos.git
TEZOS_REPO_BRANCH=m-kus@etherlink-fa-withdrawals-event-fields
CACHEBUST=${{ steps.cachebust.outputs.date }}
CI_COMMIT_SHA=dev
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta-etherlink.outputs.tags }}
labels: ${{ steps.meta-etherlink.outputs.labels }}

deploy:
if: (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'workflow_dispatch')
name: Deploy Etherlink to testnet
needs: build
runs-on: ubuntu-latest
env:
NETWORK: pariscnet
steps:
- name: Deploy rollup
run: docker run -v "/var/run/docker.sock":"/var/run/docker.sock" -e NETWORK=${{ env.NETWORK }} -e OPERATOR_KEY=${{ secrets.OPERATOR_KEY }} -e BATCHER_KEY=${{ secrets.BATCHER_KEY }} ${{ needs.build.outputs.operator }} deploy_rollup --force | tee originate.out

- name: Extract rollup address
- name: Cleanup
run: |
ROLLUP_ADDRESS=$(cat originate.out | grep -oE "sr1[a-zA-Z0-9]{33}" | uniq | tr -d '\n')
echo "ROLLUP_ADDRESS=$ROLLUP_ADDRESS" >> $GITHUB_ENV
- name: Update PR with the deployment link
if: github.event_name == 'pull_request'
uses: edumserrano/find-create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!-- pr-rollup-deployment -->'
comment-author: 'github-actions[bot]'
body: |
<!-- pr-rollup-deployment -->
Deployed at [${{ env.ROLLUP_ADDRESS }}](https://${{ env.NETWORK }}.tzkt.io/${{ env.ROLLUP_ADDRESS }})
edit-mode: replace
reactions: rocket

- name: Create GitHub deployment
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: altinukshini/deployment-action@releases/v1
id: deployment
with:
token: "${{ github.token }}"
environment: ${{ env.NETWORK }}

- name: Update deployment status
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: altinukshini/deployment-status@releases/v1
with:
token: "${{ github.token }}"
state: "success"
environment_url: https://${{ env.NETWORK }}.tzkt.io/${{ env.ROLLUP_ADDRESS }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B master -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B master --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}

0 comments on commit 5913b70

Please sign in to comment.