Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#211] Updated tags to match workflow triggers. #212

Merged
merged 5 commits into from
Oct 24, 2023

Conversation

GROwen
Copy link
Contributor

@GROwen GROwen commented Oct 24, 2023

Checklist

  • Affected Issues have been mentioned in the Closing issues section
  • Documentation has been written/updated.
  • Changelog entry has been written

Refer to #211 for detail of the scenarios.
Relevant fields in the output of each scenario

"DOCKER_META_VERSION",
"org.opencontainers.image.version",
"org.opencontainers.image.source"

Scenario

1 and 2 pull_request opened, synchronize ✅

❯ $HOME/go/src/github.com/nektos/act/dist/local/act pull_request -W .github/workflows/build-deploy.yml --defaultbranch "5.x" --actor "GROwen" -s GITHUB_TOKEN --var BRANCHES='["5.x"]' --var IMAGES='["ci-builder"]' --env REGISTRY=ghcr.io --container-architecture linux/amd64 --rm -P ubuntu-latest=catthehacker/ubuntu:act-latest -e .github/pull_request.json

pull_request.yml
{
  "action": "opened",
  "number": 86,
  "pull_request": {
    "head": {
      "ref": "build/DDS-1723--sample"
    },
    "base": {
      "ref": "5.x"
    },
    "merged": false
  }
}

Output

[build-deploy-bay-images/buildx]   ❓  ::group::Bake file definition
| {
|   "target": {
|     "docker-metadata-action": {
|       "tags": [
|         "ghcr.io/dpc-sdp/bay/ci-builder:pr-86"
|       ],
|       "labels": {
|         "maintainer": "Digital Victoria",
|         "org.opencontainers.image.authors": "Digital Victoria",
|         "org.opencontainers.image.created": "2023-10-24T03:04:18.107Z",
|         "org.opencontainers.image.description": "ci-builder image for Bay container platform",
|         "org.opencontainers.image.licenses": "",
|         "org.opencontainers.image.revision": "b611ee94e05d82f4d88a114bcf686099dfaba0c5",
|         "org.opencontainers.image.source": "https://github.com/dpc-sdp/bay/tree/build/DDS-1723--sample/images/ci-builder/Dockerfile",
|         "org.opencontainers.image.title": "ci-builder",
|         "org.opencontainers.image.url": "https://github.com/dpc-sdp/bay",
|         "org.opencontainers.image.version": "pr-86",
|         "repository": ""
|       },
|       "args": {
|         "DOCKER_META_IMAGES": "ghcr.io/dpc-sdp/bay/ci-builder",
|         "DOCKER_META_VERSION": "pr-86"
|       }
|     }
|   }
| }

3. pull_request closed and merged ✅

$HOME/go/src/github.com/nektos/act/dist/local/act pull_request -W .github/workflows/build-deploy.yml --defaultbranch "5.x" --actor "GROwen" -s GITHUB_TOKEN --var BRANCHES='["5.x"]' --var IMAGES='["ci-builder"]' --env REGISTRY=ghcr.io --container-architecture linux/amd64 --rm -P ubuntu-latest=catthehacker/ubuntu:act-latest -e .github/pull_request.json

pull_request.json

{
  "action": "closed",
  "number": 86,
  "pull_request": {
    "head": {
      "ref": "build/DDS-1723--sample"
    },
    "base": {
      "ref": "5.x"
    },
    "merged": true
  }
}

Output

[build-deploy-bay-images/buildx]   ❓  ::group::Bake file definition
| {
|   "target": {
|     "docker-metadata-action": {
|       "tags": [
|         "ghcr.io/dpc-sdp/bay/ci-builder:5.x"
|       ],
|       "labels": {
|         "maintainer": "Digital Victoria",
|         "org.opencontainers.image.authors": "Digital Victoria",
|         "org.opencontainers.image.created": "2023-10-24T02:43:56.538Z",
|         "org.opencontainers.image.description": "ci-builder image for Bay container platform",
|         "org.opencontainers.image.licenses": "",
|         "org.opencontainers.image.revision": "b611ee94e05d82f4d88a114bcf686099dfaba0c5",
|         "org.opencontainers.image.source": "https://github.com/dpc-sdp/bay/tree/5.x/images/ci-builder/Dockerfile",
|         "org.opencontainers.image.title": "ci-builder",
|         "org.opencontainers.image.url": "https://github.com/dpc-sdp/bay",
|         "org.opencontainers.image.version": "5.x",
|         "repository": ""
|       },
|       "args": {
|         "DOCKER_META_IMAGES": "ghcr.io/dpc-sdp/bay/ci-builder",
|         "DOCKER_META_VERSION": "5.x"
|       }
|     }
|   }
| }

4. Schedule ✅

Using a base branch of 6.x because of a limitation with how act calculates the ref_name for workflow triggers that don't have an associated webhook event payload i.e. schedule :)

$HOME/go/src/github.com/nektos/act/dist/local/act schedule -W .github/workflows/build-deploy.yml --actor "GROwen" -s GITHUB_TOKEN --var BRANCHES='["5.x"]' --var IMAGES='["ci-builder"]' --env REGISTRY=ghcr.io --container-architecture linux/amd64 --rm -P ubuntu-latest=catthehacker/ubuntu:act-latest

Output

[build-deploy-bay-images/buildx]   ❓  ::group::Bake file definition
| {
|   "target": {
|     "docker-metadata-action": {
|       "tags": [
|         "ghcr.io/dpc-sdp/bay/ci-builder:6.x"
|       ],
|       "labels": {
|         "maintainer": "Digital Victoria",
|         "org.opencontainers.image.authors": "Digital Victoria",
|         "org.opencontainers.image.created": "2023-10-24T02:30:36.739Z",
|         "org.opencontainers.image.description": "ci-builder image for Bay container platform",
|         "org.opencontainers.image.licenses": "",
|         "org.opencontainers.image.revision": "b611ee94e05d82f4d88a114bcf686099dfaba0c5",
|         "org.opencontainers.image.source": "https://github.com/dpc-sdp/bay/tree/6.x/images/ci-builder/Dockerfile",
|         "org.opencontainers.image.title": "ci-builder",
|         "org.opencontainers.image.url": "https://github.com/dpc-sdp/bay",
|         "org.opencontainers.image.version": "6.x",
|         "repository": ""
|       },
|       "args": {
|         "DOCKER_META_IMAGES": "ghcr.io/dpc-sdp/bay/ci-builder",
|         "DOCKER_META_VERSION": "6.x"
|       }
|     }
|   }
| }

5. workflow_dispatch ❌

I think this failure is due to an issue with act not calculating github.ref_name for workflow_dispatch but will test on GHA once this PR is published. Because workflow_dispatches aren't a critical component I'm satisfied for this to fail for now.

❯ $HOME/go/src/github.com/nektos/act/dist/local/act workflow_dispatch -W .github/workflows/build-deploy.yml --defaultbranch "5.x" --actor "GROwen" -s GITHUB_TOKEN --var BRANCHES='["5.x"]' --var IMAGES='["ci-builder"]' --env REGISTRY=ghcr.io --container-architecture linux/amd64 --rm -P ubuntu-latest=catthehacker/ubuntu:act-latest -e .github/workflow_dispatch.json

workflow_dispatch.json
{
  "inputs": null,
  "ref": "5.x",
  "repo": "dpc-sdp/bay",
  "sender": "GROwen",
  "workflow": "test-context-values"
}

Output

[build-deploy-bay-images/buildx]   ❓  ::group::Bake file definition
| {
|   "target": {
|     "docker-metadata-action": {
|       "tags": [],
|       "labels": {
|         "maintainer": "Digital Victoria",
|         "org.opencontainers.image.authors": "Digital Victoria",
|         "org.opencontainers.image.created": "2023-10-24T03:23:18.969Z",
|         "org.opencontainers.image.description": "ci-builder image for Bay container platform",
|         "org.opencontainers.image.licenses": "",
|         "org.opencontainers.image.revision": "b611ee94e05d82f4d88a114bcf686099dfaba0c5",
|         "org.opencontainers.image.source": "https://github.com/dpc-sdp/bay/tree//images/ci-builder/Dockerfile",
|         "org.opencontainers.image.title": "ci-builder",
|         "org.opencontainers.image.url": "https://github.com/dpc-sdp/bay",
|         "org.opencontainers.image.version": "",
|         "repository": ""
|       },
|       "args": {
|         "DOCKER_META_IMAGES": "ghcr.io/dpc-sdp/bay/ci-builder"
|       }
|     }
|   }
| }

Changelog Entry

Refactors the workflow event triggers and associated tag assignment so that the expected behaviour for the scenarios outlined in issue #211 are met.

Closing issues

Closes #211

@GROwen GROwen added the NEEDS REVIEW Good for newcomers label Oct 24, 2023
@GROwen GROwen self-assigned this Oct 24, 2023
org.opencontainers.image.title=${{ matrix.images }}
org.opencontainers.image.description=${{ matrix.images }} image for Bay container platform

- name: Build and push the images
if: ${{ !env.ACT }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't and it's gone 😄


`build/2.x-updated-cli` will generate the tag `build-2-x-updated-cli` and would be referenced as `ghcr.io/dpc-sdp/bay/<bay-image>:build-2-x-updated-cli`.
### Development builds
GitHub Actions is configured via the [build-deploy workflow](.github/workflows/build-deploy.yml) to build images for pull requests when they are opened and receive updates. These images are tagged with the PR number i.e. pr-86.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@GROwen
Copy link
Contributor Author

GROwen commented Oct 24, 2023

Just wanted to make sure the images are tagged correctly, and they are 🎉

@GROwen GROwen merged commit 6ef4fb5 into 5.x Oct 24, 2023
9 checks passed
@GROwen GROwen deleted the build/DDS-1723--build-on-merge-fix branch October 24, 2023 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NEEDS REVIEW Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tags are not set correctly
2 participants